import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M)));
        double ans = Math.sqrt(x2);
        
        System.out.println(ans);

        sc.close();
    }
    
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M)));
        double ans = Math.sqrt(x2);
        
        System.out.println(ans);

        sc.close();
    }
    
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M)));
        double ans = Math.sqrt(x2);
        
        System.out.println(ans);

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M)));
        double ans = Math.sqrt(x2);
        
        System.out.println(ans);

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = Integer.parseInt(sc.next()); A Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int B = Integer.parseInt(sc.next()); B Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int H = Integer.parseInt(sc.next()); H Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int M = Integer.parseInt(sc.next()); M Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M))); x2 A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M))) A*A + B*B A*A A A B*B B B 2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M))) B 2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M))) 2 A B (Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M))) Math.cos Math Math.toRadians(30*H+(double)(M/2.0)-6*M) Math.toRadians Math 30*H+(double)(M/2.0)-6*M 30*H+(double)(M/2.0) 30*H 30 H (double)(M/2.0) M 2.0 6*M 6 M double ans = Math.sqrt(x2); ans Math.sqrt(x2) Math.sqrt Math x2 System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String args[] args public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M)));
        double ans = Math.sqrt(x2);
        
        System.out.println(ans);

        sc.close();
    }
    
} public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M)));
        double ans = Math.sqrt(x2);
        
        System.out.println(ans);

        sc.close();
    }
    
} Main
import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        double x2 = A*A + B*B -2*A*B*(Math.cos(Math.toRadians(30*H+(double)(M/2.0)-6*M)));
        double ans = Math.sqrt(x2);
        
        System.out.println(ans);

        sc.close();
    }
    
}