import java.util.*;
import static java.lang.Math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextInt();
        double b = scan.nextInt();
        double h = scan.nextInt();
        double m = scan.nextInt();
        double ans;
        
        //角速度（分針）
        //System.out.println(Math.PI);
        //double m1 = 2*(Math.PI)/3600;
        
        //角速度（時針）
        //double h1 = 2*(Math.PI)/43200;
        
        //分針と時針が作る角度
        //角速度（時針）

        double k = Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h);
        //System.out.println(k);
        if(k>180 && k!=360){
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        }
        System.out.println(ans);
    }
}
         import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextInt();
        double b = scan.nextInt();
        double h = scan.nextInt();
        double m = scan.nextInt();
        double ans;
        
        //角速度（分針）
        //System.out.println(Math.PI);
        //double m1 = 2*(Math.PI)/3600;
        
        //角速度（時針）
        //double h1 = 2*(Math.PI)/43200;
        
        //分針と時針が作る角度
        //角速度（時針）

        double k = Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h);
        //System.out.println(k);
        if(k>180 && k!=360){
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextInt();
        double b = scan.nextInt();
        double h = scan.nextInt();
        double m = scan.nextInt();
        double ans;
        
        //角速度（分針）
        //System.out.println(Math.PI);
        //double m1 = 2*(Math.PI)/3600;
        
        //角速度（時針）
        //double h1 = 2*(Math.PI)/43200;
        
        //分針と時針が作る角度
        //角速度（時針）

        double k = Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h);
        //System.out.println(k);
        if(k>180 && k!=360){
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        }
        System.out.println(ans);
    } main {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextInt();
        double b = scan.nextInt();
        double h = scan.nextInt();
        double m = scan.nextInt();
        double ans;
        
        //角速度（分針）
        //System.out.println(Math.PI);
        //double m1 = 2*(Math.PI)/3600;
        
        //角速度（時針）
        //double h1 = 2*(Math.PI)/43200;
        
        //分針と時針が作る角度
        //角速度（時針）

        double k = Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h);
        //System.out.println(k);
        if(k>180 && k!=360){
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        }
        System.out.println(ans);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) double a = scan.nextInt(); a scan.nextInt() scan.nextInt scan double b = scan.nextInt(); b scan.nextInt() scan.nextInt scan double h = scan.nextInt(); h scan.nextInt() scan.nextInt scan double m = scan.nextInt(); m scan.nextInt() scan.nextInt scan double ans; ans double k = Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h); k Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h) Math.abs Math 5.500000000000000000000000000*m-30.000000000000000000000000000*h 5.500000000000000000000000000*m 5.500000000000000000000000000 m 30.000000000000000000000000000*h 30.000000000000000000000000000 h if(k>180 && k!=360){
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        } k>180 && k!=360 k>180 k 180 k!=360 k 360 {
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        } ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k)))) ans Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k)))) Math.sqrt Math a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))) a*a+b*b a*a a a b*b b b 2*a*b*(Math.cos(Math.toRadians(k))) b 2*a*b*(Math.cos(Math.toRadians(k))) 2 a b (Math.cos(Math.toRadians(k))) Math.cos Math Math.toRadians(k) Math.toRadians Math k if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        } k<180 k 180 {
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        } ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k)))) ans Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k)))) Math.sqrt Math a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))) a*a+b*b a*a a a b*b b b 2*a*b*(Math.cos(Math.toRadians(k))) b 2*a*b*(Math.cos(Math.toRadians(k))) 2 a b (Math.cos(Math.toRadians(k))) Math.cos Math Math.toRadians(k) Math.toRadians Math k if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        } k==180 k 180 {
            ans=a+b;
        } ans=a+b ans a+b a b {
             ans = Math.abs(a-b);
        } ans = Math.abs(a-b) ans Math.abs(a-b) Math.abs Math a-b a b System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextInt();
        double b = scan.nextInt();
        double h = scan.nextInt();
        double m = scan.nextInt();
        double ans;
        
        //角速度（分針）
        //System.out.println(Math.PI);
        //double m1 = 2*(Math.PI)/3600;
        
        //角速度（時針）
        //double h1 = 2*(Math.PI)/43200;
        
        //分針と時針が作る角度
        //角速度（時針）

        double k = Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h);
        //System.out.println(k);
        if(k>180 && k!=360){
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextInt();
        double b = scan.nextInt();
        double h = scan.nextInt();
        double m = scan.nextInt();
        double ans;
        
        //角速度（分針）
        //System.out.println(Math.PI);
        //double m1 = 2*(Math.PI)/3600;
        
        //角速度（時針）
        //double h1 = 2*(Math.PI)/43200;
        
        //分針と時針が作る角度
        //角速度（時針）

        double k = Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h);
        //System.out.println(k);
        if(k>180 && k!=360){
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        }
        System.out.println(ans);
    }
} Main
import java.util.*;
import static java.lang.Math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextInt();
        double b = scan.nextInt();
        double h = scan.nextInt();
        double m = scan.nextInt();
        double ans;
        
        //角速度（分針）
        //System.out.println(Math.PI);
        //double m1 = 2*(Math.PI)/3600;
        
        //角速度（時針）
        //double h1 = 2*(Math.PI)/43200;
        
        //分針と時針が作る角度
        //角速度（時針）

        double k = Math.abs(5.500000000000000000000000000*m-30.000000000000000000000000000*h);
        //System.out.println(k);
        if(k>180 && k!=360){
            //k=k-180;
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k<180){
            ans= Math.sqrt(a*a+b*b-2*a*b*(Math.cos(Math.toRadians(k))));
        }else if(k==180){
            ans=a+b;
        }else{
             ans = Math.abs(a-b);
        }
        System.out.println(ans);
    }
}
        