import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void fun(int a, int b, int h, int m) {

        double oneH = 2 * Math.PI / 12.0;
        double angleH = oneH * (h + m / 60.0);
        double oneM = 2 * Math.PI / 60.0;
        double angleM = oneM * m;

//        double angle = angleH - angleM;
        double angle = angleM - angleH;


        double ans = a * a + b * b - 2 * a * b * Math.cos(angle);
        System.out.println(Math.sqrt(ans));
    }



    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] ss=line.split(" ");
        int a = Integer.valueOf(ss[0]);
        int b = Integer.valueOf(ss[1]);
        int h = Integer.valueOf(ss[2]);
        int m = Integer.valueOf(ss[3]);
        fun(a, b, h, m);
    }



}

/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