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 = H * 360 / 12.0 + M * 360 / 60.0 / 12.0;
        double min =  M * 360 / 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(Math.toRadians(degree)));
        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();
        double hour = H * 360 / 12.0 + M * 360 / 60.0 / 12.0;
        double min =  M * 360 / 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(Math.toRadians(degree)));
        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();
        double hour = H * 360 / 12.0 + M * 360 / 60.0 / 12.0;
        double min =  M * 360 / 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(Math.toRadians(degree)));
        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();
        double hour = H * 360 / 12.0 + M * 360 / 60.0 / 12.0;
        double min =  M * 360 / 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(Math.toRadians(degree)));
        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 double hour = H * 360 / 12.0 + M * 360 / 60.0 / 12.0; hour H * 360 / 12.0 + M * 360 / 60.0 / 12.0 H * 360 / 12.0 H * 360 H 360 12.0 M * 360 / 60.0 / 12.0 M * 360 / 60.0 / 12.0 M * 360 M 360 60.0 12.0 double min =  M * 360 / 60.0; min M * 360 / 60.0 M * 360 M 360 60.0 double diff = Math.abs(hour - min); diff Math.abs(hour - min) Math.abs Math hour - min hour min double degree = Math.min(diff, 360 - diff); degree Math.min(diff, 360 - diff) Math.min Math diff 360 - diff 360 diff double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree))); ans Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree))) Math.sqrt Math A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)) A * A + B * B A * A A A B * B B B 2 * A * B * Math.cos(Math.toRadians(degree)) B 2 * A * B * Math.cos(Math.toRadians(degree)) 2 A B Math.cos(Math.toRadians(degree)) Math.cos Math Math.toRadians(degree) Math.toRadians Math degree 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 = H * 360 / 12.0 + M * 360 / 60.0 / 12.0;
        double min =  M * 360 / 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(Math.toRadians(degree)));
        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();
        double hour = H * 360 / 12.0 + M * 360 / 60.0 / 12.0;
        double min =  M * 360 / 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(Math.toRadians(degree)));
        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();
        double hour = H * 360 / 12.0 + M * 360 / 60.0 / 12.0;
        double min =  M * 360 / 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(Math.toRadians(degree)));
        System.out.println(ans);
    }
}