import java.util.*;
public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
        double rad;
        double ans;

        rad = (double)((h*30)-(m*5.5));
        rad *= (rad<=0)?-1:1;
        rad = (rad>=180)?360-rad:rad;

        ans = (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad))));
        ans = Math.sqrt(ans);

        System.out.println(ans);

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
        double rad;
        double ans;

        rad = (double)((h*30)-(m*5.5));
        rad *= (rad<=0)?-1:1;
        rad = (rad>=180)?360-rad:rad;

        ans = (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad))));
        ans = Math.sqrt(ans);

        System.out.println(ans);

    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
        double rad;
        double ans;

        rad = (double)((h*30)-(m*5.5));
        rad *= (rad<=0)?-1:1;
        rad = (rad>=180)?360-rad:rad;

        ans = (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad))));
        ans = Math.sqrt(ans);

        System.out.println(ans);

    } main {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
        double rad;
        double ans;

        rad = (double)((h*30)-(m*5.5));
        rad *= (rad<=0)?-1:1;
        rad = (rad>=180)?360-rad:rad;

        ans = (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad))));
        ans = Math.sqrt(ans);

        System.out.println(ans);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc sc.close() sc.close sc double rad; rad double ans; ans rad = (double)((h*30)-(m*5.5)) rad (double)((h*30)-(m*5.5)) (h*30) h 30 (m*5.5) m 5.5 rad *= (rad<=0)?-1:1 rad (rad<=0)?-1:1 (rad<=0) rad 0 -1 1 1 rad = (rad>=180)?360-rad:rad rad (rad>=180)?360-rad:rad (rad>=180) rad 180 360-rad 360 rad rad ans = (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad)))) ans (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad)))) (a*a)+(b*b) (a*a) a a (b*b) b b ((2*a*b)*(Math.cos(Math.toRadians(rad)))) (2*a*b) 2*a*b 2 a b (Math.cos(Math.toRadians(rad))) Math.cos Math Math.toRadians(rad) Math.toRadians Math rad ans = Math.sqrt(ans) ans Math.sqrt(ans) Math.sqrt Math ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
        double rad;
        double ans;

        rad = (double)((h*30)-(m*5.5));
        rad *= (rad<=0)?-1:1;
        rad = (rad>=180)?360-rad:rad;

        ans = (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad))));
        ans = Math.sqrt(ans);

        System.out.println(ans);

    }
} public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
        double rad;
        double ans;

        rad = (double)((h*30)-(m*5.5));
        rad *= (rad<=0)?-1:1;
        rad = (rad>=180)?360-rad:rad;

        ans = (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad))));
        ans = Math.sqrt(ans);

        System.out.println(ans);

    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
        double rad;
        double ans;

        rad = (double)((h*30)-(m*5.5));
        rad *= (rad<=0)?-1:1;
        rad = (rad>=180)?360-rad:rad;

        ans = (a*a)+(b*b)-((2*a*b)*(Math.cos(Math.toRadians(rad))));
        ans = Math.sqrt(ans);

        System.out.println(ans);

    }
}
