import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();

        final double SHORT_HAND_ANGLE_PER_MINUTE = 0.5;
        final double LONG_HAND_ANGLE_PER_MINUTE = 6;

        double angleHour = (h * 60 + m) * SHORT_HAND_ANGLE_PER_MINUTE;
        double angleMinute = m * LONG_HAND_ANGLE_PER_MINUTE;

        double eggplantAngle = 0;
        if(angleHour <= angleMinute){
            eggplantAngle = angleMinute - angleHour;
        }else{
            eggplantAngle = angleHour - angleMinute;
        }

        if(eggplantAngle > 180){
            eggplantAngle = 360 - eggplantAngle;
        }

        double radian = Math.toRadians(eggplantAngle);

        double c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(radian));
        System.out.println(c);
    }
}

/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