import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        
        //短針
        double S = 30*H+0.5*M;  
        //長針
        double L = 6*M;
        
        double angle = Math.abs(L-S);
        
        if(angle>180){
            angle = Math.abs(angle-360);
        }
        
        angle = Math.toRadians(angle);
        
        System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)));
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        
        //短針
        double S = 30*H+0.5*M;  
        //長針
        double L = 6*M;
        
        double angle = Math.abs(L-S);
        
        if(angle>180){
            angle = Math.abs(angle-360);
        }
        
        angle = Math.toRadians(angle);
        
        System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)));
        
    }
} Main public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        
        //短針
        double S = 30*H+0.5*M;  
        //長針
        double L = 6*M;
        
        double angle = Math.abs(L-S);
        
        if(angle>180){
            angle = Math.abs(angle-360);
        }
        
        angle = Math.toRadians(angle);
        
        System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)));
        
    } main {
        
        Scanner scanner = new Scanner(System.in);
        
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        
        //短針
        double S = 30*H+0.5*M;  
        //長針
        double L = 6*M;
        
        double angle = Math.abs(L-S);
        
        if(angle>180){
            angle = Math.abs(angle-360);
        }
        
        angle = Math.toRadians(angle);
        
        System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)));
        
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner int H = scanner.nextInt(); H scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner double S = 30*H+0.5*M; S 30*H+0.5*M 30*H 30 H 0.5*M 0.5 M double L = 6*M; L 6*M 6 M double angle = Math.abs(L-S); angle Math.abs(L-S) Math.abs Math L-S L S if(angle>180){
            angle = Math.abs(angle-360);
        } angle>180 angle 180 {
            angle = Math.abs(angle-360);
        } angle = Math.abs(angle-360) angle Math.abs(angle-360) Math.abs Math angle-360 angle 360 angle = Math.toRadians(angle) angle Math.toRadians(angle) Math.toRadians Math angle System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle))) System.out.println System.out System System.out Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)) Math.sqrt Math A*A+B*B-2*A*B*Math.cos(angle) A*A+B*B A*A A A B*B B B 2*A*B*Math.cos(angle) B 2*A*B*Math.cos(angle) 2 A B Math.cos(angle) Math.cos Math angle String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        
        //短針
        double S = 30*H+0.5*M;  
        //長針
        double L = 6*M;
        
        double angle = Math.abs(L-S);
        
        if(angle>180){
            angle = Math.abs(angle-360);
        }
        
        angle = Math.toRadians(angle);
        
        System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)));
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        
        //短針
        double S = 30*H+0.5*M;  
        //長針
        double L = 6*M;
        
        double angle = Math.abs(L-S);
        
        if(angle>180){
            angle = Math.abs(angle-360);
        }
        
        angle = Math.toRadians(angle);
        
        System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)));
        
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        
        //短針
        double S = 30*H+0.5*M;  
        //長針
        double L = 6*M;
        
        double angle = Math.abs(L-S);
        
        if(angle>180){
            angle = Math.abs(angle-360);
        }
        
        angle = Math.toRadians(angle);
        
        System.out.println(Math.sqrt(A*A+B*B-2*A*B*Math.cos(angle)));
        
    }
}
