import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int h=scn.nextInt();
        int m=scn.nextInt();
        double a_angle=h*(360/12)+m*0.5;
        double b_angle=m*(360/60);
        double c=a_angle-b_angle;
        if(c<0) c+=360;
        
        System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c))));
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int h=scn.nextInt();
        int m=scn.nextInt();
        double a_angle=h*(360/12)+m*0.5;
        double b_angle=m*(360/60);
        double c=a_angle-b_angle;
        if(c<0) c+=360;
        
        System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c))));
    }
} Main public static void main(String[] args) throws Exception {
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int h=scn.nextInt();
        int m=scn.nextInt();
        double a_angle=h*(360/12)+m*0.5;
        double b_angle=m*(360/60);
        double c=a_angle-b_angle;
        if(c<0) c+=360;
        
        System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c))));
    } main {
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int h=scn.nextInt();
        int m=scn.nextInt();
        double a_angle=h*(360/12)+m*0.5;
        double b_angle=m*(360/60);
        double c=a_angle-b_angle;
        if(c<0) c+=360;
        
        System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c))));
    } Scanner scn=new Scanner(System.in); scn new Scanner(System.in) int a=scn.nextInt(); a scn.nextInt() scn.nextInt scn int b=scn.nextInt(); b scn.nextInt() scn.nextInt scn int h=scn.nextInt(); h scn.nextInt() scn.nextInt scn int m=scn.nextInt(); m scn.nextInt() scn.nextInt scn double a_angle=h*(360/12)+m*0.5; a_angle h*(360/12)+m*0.5 h*(360/12) h (360/12) 360 12 m*0.5 m 0.5 double b_angle=m*(360/60); b_angle m*(360/60) m (360/60) 360 60 double c=a_angle-b_angle; c a_angle-b_angle a_angle b_angle if(c<0) c+=360; c<0 c 0 c+=360 c 360 System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c)))) System.out.println System.out System System.out Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c))) Math.sqrt Math a*a+b*b-2*a*b*Math.cos(Math.toRadians(c)) a*a+b*b a*a a a b*b b b 2*a*b*Math.cos(Math.toRadians(c)) b 2*a*b*Math.cos(Math.toRadians(c)) 2 a b Math.cos(Math.toRadians(c)) Math.cos Math Math.toRadians(c) Math.toRadians Math c String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int h=scn.nextInt();
        int m=scn.nextInt();
        double a_angle=h*(360/12)+m*0.5;
        double b_angle=m*(360/60);
        double c=a_angle-b_angle;
        if(c<0) c+=360;
        
        System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c))));
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int h=scn.nextInt();
        int m=scn.nextInt();
        double a_angle=h*(360/12)+m*0.5;
        double b_angle=m*(360/60);
        double c=a_angle-b_angle;
        if(c<0) c+=360;
        
        System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c))));
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scn=new Scanner(System.in);
        int a=scn.nextInt();
        int b=scn.nextInt();
        int h=scn.nextInt();
        int m=scn.nextInt();
        double a_angle=h*(360/12)+m*0.5;
        double b_angle=m*(360/60);
        double c=a_angle-b_angle;
        if(c<0) c+=360;
        
        System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.toRadians(c))));
    }
}
