import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        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 kakudoA = (double) (0.5 * (H * 60 + M));
        double kakudoB = (double) (6 * M);
        double kakudoC = Math.abs(kakudoA - kakudoB);

        double c = 0;
        if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        }
        System.out.println(c);
        return;
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz