import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        int H = sc.nextInt(), M = sc.nextInt();
        
        double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0));
        
        double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta));
        
        System.out.println(sqr);
    }
} import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        int H = sc.nextInt(), M = sc.nextInt();
        
        double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0));
        
        double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta));
        
        System.out.println(sqr);
    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        int H = sc.nextInt(), M = sc.nextInt();
        
        double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0));
        
        double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta));
        
        System.out.println(sqr);
    } main {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        int H = sc.nextInt(), M = sc.nextInt();
        
        double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0));
        
        double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta));
        
        System.out.println(sqr);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt() A sc.nextInt() sc.nextInt sc B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int H = sc.nextInt() H sc.nextInt() sc.nextInt sc M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0)); theta (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0)) (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0)) (double)2 Math.PI Math Math.PI ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0)) (double)M / 60.0 (double)M 60.0 ((60.0 * (double)H + M) / 720.0) (60.0 * (double)H + M) 60.0 * (double)H 60.0 (double)H M 720.0 double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta)); sqr Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta)) Math.sqrt Math (double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta) (double)(A*A + B * B) A*A A A B * B B B 2 * (double)(A * B) * Math.cos(theta) 2 * (double)(A * B) * Math.cos(theta) 2 (double)(A * B) A B Math.cos(theta) Math.cos Math theta System.out.println(sqr) System.out.println System.out System System.out sqr String[] args args public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        int H = sc.nextInt(), M = sc.nextInt();
        
        double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0));
        
        double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta));
        
        System.out.println(sqr);
    }
} public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        int H = sc.nextInt(), M = sc.nextInt();
        
        double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0));
        
        double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta));
        
        System.out.println(sqr);
    }
} Main
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        int H = sc.nextInt(), M = sc.nextInt();
        
        double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0));
        
        double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta));
        
        System.out.println(sqr);
    }
}