import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double A = sc.nextInt();
        double B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();
        double ans;
        
        double sho = (H * 60 + M) * 360 / ( 12 * 60 );
        double lon = M * 360 / 60;
        double ang;
        
        ang = Math.abs(sho - lon);
        
        ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)));
        
        System.out.print(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double A = sc.nextInt();
        double B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();
        double ans;
        
        double sho = (H * 60 + M) * 360 / ( 12 * 60 );
        double lon = M * 360 / 60;
        double ang;
        
        ang = Math.abs(sho - lon);
        
        ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)));
        
        System.out.print(ans);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double A = sc.nextInt();
        double B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();
        double ans;
        
        double sho = (H * 60 + M) * 360 / ( 12 * 60 );
        double lon = M * 360 / 60;
        double ang;
        
        ang = Math.abs(sho - lon);
        
        ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)));
        
        System.out.print(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextInt();
        double B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();
        double ans;
        
        double sho = (H * 60 + M) * 360 / ( 12 * 60 );
        double lon = M * 360 / 60;
        double ang;
        
        ang = Math.abs(sho - lon);
        
        ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)));
        
        System.out.print(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double A = sc.nextInt(); A sc.nextInt() sc.nextInt sc double B = sc.nextInt(); B sc.nextInt() sc.nextInt sc double H = sc.nextInt(); H sc.nextInt() sc.nextInt sc double M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double ans; ans double sho = (H * 60 + M) * 360 / ( 12 * 60 ); sho (H * 60 + M) * 360 / ( 12 * 60 ) (H * 60 + M) * 360 (H * 60 + M) H * 60 H 60 M 360 ( 12 * 60 ) 12 60 double lon = M * 360 / 60; lon M * 360 / 60 M * 360 M 360 60 double ang; ang ang = Math.abs(sho - lon) ang Math.abs(sho - lon) Math.abs Math sho - lon sho lon ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang))) ans Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang))) Math.sqrt Math A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)) A * A + B * B A * A A A B * B B B 2.0 * A * B * Math.cos(Math.toRadians(ang)) B 2.0 * A * B * Math.cos(Math.toRadians(ang)) 2.0 A B Math.cos(Math.toRadians(ang)) Math.cos Math Math.toRadians(ang) Math.toRadians Math ang System.out.print(ans) System.out.print System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double A = sc.nextInt();
        double B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();
        double ans;
        
        double sho = (H * 60 + M) * 360 / ( 12 * 60 );
        double lon = M * 360 / 60;
        double ang;
        
        ang = Math.abs(sho - lon);
        
        ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)));
        
        System.out.print(ans);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double A = sc.nextInt();
        double B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();
        double ans;
        
        double sho = (H * 60 + M) * 360 / ( 12 * 60 );
        double lon = M * 360 / 60;
        double ang;
        
        ang = Math.abs(sho - lon);
        
        ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)));
        
        System.out.print(ans);
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double A = sc.nextInt();
        double B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();
        double ans;
        
        double sho = (H * 60 + M) * 360 / ( 12 * 60 );
        double lon = M * 360 / 60;
        double ang;
        
        ang = Math.abs(sho - lon);
        
        ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)));
        
        System.out.print(ans);
    }
}