
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int A = sc.nextInt();
    static int B = sc.nextInt();
    static int H = sc.nextInt();
    static int M = sc.nextInt();

    public static void main(String[] args) {
        //角度を求める
        double kHour = H * 30 + M * 0.5;
        double kMin = M * 6;
        double kakudo = kHour - kMin;
        if (kakudo > 180){
            kakudo = 360 - kakudo;
        } else if (kakudo < 0){
            kakudo *= -1;
        }
        double dC = A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudo));
//        BigDecimal x = new BigDecimal(Math.sqrt(dC));
//        MathContext mc = new MathContext(50, RoundingMode.UP);
//        BigDecimal result = x.round(mc);
        double result = Math.sqrt(dC);
        System.out.print(result);

    }

}
/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