import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     int H = sc.nextInt();
     int M = sc.nextInt();
     
     double rad = 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60; 
     double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad));
     
     System.out.println(C);
     }
    
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     int H = sc.nextInt();
     int M = sc.nextInt();
     
     double rad = 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60; 
     double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad));
     
     System.out.println(C);
     }
    
} Main public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     int H = sc.nextInt();
     int M = sc.nextInt();
     
     double rad = 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60; 
     double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad));
     
     System.out.println(C);
     } main {
       Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     int H = sc.nextInt();
     int M = sc.nextInt();
     
     double rad = 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60; 
     double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad));
     
     System.out.println(C);
     } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double rad = 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60; rad 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60 2*Math.PI*(H+M/60.0)/12 2*Math.PI*(H+M/60.0) 2*Math.PI*(H+M/60.0) 2 Math.PI Math Math.PI (H+M/60.0) H M/60.0 M 60.0 12 2*Math.PI*M/60 2*Math.PI*M 2*Math.PI*M 2 Math.PI Math Math.PI M 60 double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad)); C Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad)) Math.sqrt Math A*A+B*B-2*A*B*Math.cos(rad) A*A+B*B A*A A A B*B B B 2*A*B*Math.cos(rad) B 2*A*B*Math.cos(rad) 2 A B Math.cos(rad) Math.cos Math rad System.out.println(C) System.out.println System.out System System.out C String[] args args public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     int H = sc.nextInt();
     int M = sc.nextInt();
     
     double rad = 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60; 
     double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad));
     
     System.out.println(C);
     }
    
} public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     int H = sc.nextInt();
     int M = sc.nextInt();
     
     double rad = 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60; 
     double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad));
     
     System.out.println(C);
     }
    
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     int H = sc.nextInt();
     int M = sc.nextInt();
     
     double rad = 2*Math.PI*(H+M/60.0)/12-2*Math.PI*M/60; 
     double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rad));
     
     System.out.println(C);
     }
    
}
