import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int H=sc.nextInt();
        int M=sc.nextInt();

        double longW=((H%12)*30)+(M*0.5); //長針のデフォルトからの角度
        double shortW=M*6; //短針のデフォルトからの角度

        //System.out.print(longW);
        //System.out.print(" ");
        //System.out.println(shortW);

        double W=longW-shortW;

        if(W<0){
            W=Math.abs(longW-shortW);
        }else if(W>180){
            W=360-W;
        }

        //System.out.println(W);

        double cosW=0;

        if(W==90){
            cosW=0;
        }else{
            cosW=Math.cos(Math.toRadians(W));
        }

        //System.out.println(cosW);

        double JIJOU=A*A+B*B-2*A*B*cosW;

        //System.out.println(A*A+"と"+B*B+"と"+2*A*B*cosW);
        //System.out.println(JIJOU);

        double ans=Math.sqrt(JIJOU);

        System.out.println(String.format("%.15f", ans));
        //END

    }
}


/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