import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String A = scan.next();
        int a = Integer.parseInt(A);
        String B = scan.next();
        int b = Integer.parseInt(B);
        String H = scan.next();
        int h = Integer.parseInt(H);
        String M = scan.next();
        int m = Integer.parseInt(M);

        double angle = Math.abs((30 * h + 0.5 * m) - 6 * m);
        double cos = Math.cos(Math.toRadians(angle));

        double ans;
        if (angle == 0) {
            ans = Math.abs(a - b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * cos));
        }

        System.out.println(ans);
    }
}
/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