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 l = m*6;
        double s = h*30+m*0.5;
        double cos;
        if (Math.abs(l-s) > 180) {
            cos = 360 - Math.abs(l-s);
        } else {
            cos = Math.abs(l-s);
        }
        double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos));
        double c = Math.sqrt(c2);

        System.out.println(c);
        
    }
} 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 l = m*6;
        double s = h*30+m*0.5;
        double cos;
        if (Math.abs(l-s) > 180) {
            cos = 360 - Math.abs(l-s);
        } else {
            cos = Math.abs(l-s);
        }
        double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos));
        double c = Math.sqrt(c2);

        System.out.println(c);
        
    }
} 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 l = m*6;
        double s = h*30+m*0.5;
        double cos;
        if (Math.abs(l-s) > 180) {
            cos = 360 - Math.abs(l-s);
        } else {
            cos = Math.abs(l-s);
        }
        double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos));
        double c = Math.sqrt(c2);

        System.out.println(c);
        
    } 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 l = m*6;
        double s = h*30+m*0.5;
        double cos;
        if (Math.abs(l-s) > 180) {
            cos = 360 - Math.abs(l-s);
        } else {
            cos = Math.abs(l-s);
        }
        double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos));
        double c = Math.sqrt(c2);

        System.out.println(c);
        
    } 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 l = m*6; l m*6 m 6 double s = h*30+m*0.5; s h*30+m*0.5 h*30 h 30 m*0.5 m 0.5 double cos; cos if (Math.abs(l-s) > 180) {
            cos = 360 - Math.abs(l-s);
        } else {
            cos = Math.abs(l-s);
        } Math.abs(l-s) > 180 Math.abs(l-s) Math.abs Math l-s l s 180 {
            cos = 360 - Math.abs(l-s);
        } cos = 360 - Math.abs(l-s) cos 360 - Math.abs(l-s) 360 Math.abs(l-s) Math.abs Math l-s l s {
            cos = Math.abs(l-s);
        } cos = Math.abs(l-s) cos Math.abs(l-s) Math.abs Math l-s l s double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos)); c2 Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos)) Math.pow(a, 2) + Math.pow(b, 2) Math.pow(a, 2) Math.pow Math a 2 Math.pow(b, 2) Math.pow Math b 2 2*a*b*Math.cos(Math.toRadians(cos)) b 2*a*b*Math.cos(Math.toRadians(cos)) 2 a b Math.cos(Math.toRadians(cos)) Math.cos Math Math.toRadians(cos) Math.toRadians Math cos double c = Math.sqrt(c2); c Math.sqrt(c2) Math.sqrt Math c2 System.out.println(c) System.out.println System.out System System.out c 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 l = m*6;
        double s = h*30+m*0.5;
        double cos;
        if (Math.abs(l-s) > 180) {
            cos = 360 - Math.abs(l-s);
        } else {
            cos = Math.abs(l-s);
        }
        double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos));
        double c = Math.sqrt(c2);

        System.out.println(c);
        
    }
} 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 l = m*6;
        double s = h*30+m*0.5;
        double cos;
        if (Math.abs(l-s) > 180) {
            cos = 360 - Math.abs(l-s);
        } else {
            cos = Math.abs(l-s);
        }
        double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos));
        double c = Math.sqrt(c2);

        System.out.println(c);
        
    }
} 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 l = m*6;
        double s = h*30+m*0.5;
        double cos;
        if (Math.abs(l-s) > 180) {
            cos = 360 - Math.abs(l-s);
        } else {
            cos = Math.abs(l-s);
        }
        double c2 = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(cos));
        double c = Math.sqrt(c2);

        System.out.println(c);
        
    }
}