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();
        double hour = 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0);
        double min =  2*Math.PI * M / 60.0;
//        double diff = Math.abs(hour - min);
//        System.out.println(diff);
//        double degree = Math.min(diff, 360 - diff);
//        System.out.println(degree);
        double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min));
        System.out.println(ans);
//        System.out.printf("%.12f\n", 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();
        double hour = 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0);
        double min =  2*Math.PI * M / 60.0;
//        double diff = Math.abs(hour - min);
//        System.out.println(diff);
//        double degree = Math.min(diff, 360 - diff);
//        System.out.println(degree);
        double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min));
        System.out.println(ans);
//        System.out.printf("%.12f\n", 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();
        double hour = 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0);
        double min =  2*Math.PI * M / 60.0;
//        double diff = Math.abs(hour - min);
//        System.out.println(diff);
//        double degree = Math.min(diff, 360 - diff);
//        System.out.println(degree);
        double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min));
        System.out.println(ans);
//        System.out.printf("%.12f\n", ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        double hour = 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0);
        double min =  2*Math.PI * M / 60.0;
//        double diff = Math.abs(hour - min);
//        System.out.println(diff);
//        double degree = Math.min(diff, 360 - diff);
//        System.out.println(degree);
        double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min));
        System.out.println(ans);
//        System.out.printf("%.12f\n", 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 double hour = 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0); hour 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0) 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0) 2 Math.PI Math Math.PI (H / 12.0 + M / 60.0 / 12.0) H / 12.0 H 12.0 M / 60.0 / 12.0 M / 60.0 / 12.0 M 60.0 12.0 double min =  2*Math.PI * M / 60.0; min 2*Math.PI * M / 60.0 2*Math.PI * M 2*Math.PI * M 2 Math.PI Math Math.PI M 60.0 double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min)); ans Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min)) Math.sqrt Math A * A + B * B - 2 * A * B * Math.cos(hour - min) A * A + B * B A * A A A B * B B B 2 * A * B * Math.cos(hour - min) B 2 * A * B * Math.cos(hour - min) 2 A B Math.cos(hour - min) Math.cos Math hour - min hour min 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();
        double hour = 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0);
        double min =  2*Math.PI * M / 60.0;
//        double diff = Math.abs(hour - min);
//        System.out.println(diff);
//        double degree = Math.min(diff, 360 - diff);
//        System.out.println(degree);
        double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min));
        System.out.println(ans);
//        System.out.printf("%.12f\n", 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();
        double hour = 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0);
        double min =  2*Math.PI * M / 60.0;
//        double diff = Math.abs(hour - min);
//        System.out.println(diff);
//        double degree = Math.min(diff, 360 - diff);
//        System.out.println(degree);
        double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min));
        System.out.println(ans);
//        System.out.printf("%.12f\n", 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();
        double hour = 2*Math.PI * (H / 12.0 + M / 60.0 / 12.0);
        double min =  2*Math.PI * M / 60.0;
//        double diff = Math.abs(hour - min);
//        System.out.println(diff);
//        double degree = Math.min(diff, 360 - diff);
//        System.out.println(degree);
        double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(hour - min));
        System.out.println(ans);
//        System.out.printf("%.12f\n", ans);
    }
}