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();
		
		int pass_time = H*60 + M;
      	
		double a = ((double)360/60/12 * (double)pass_time) % 360;
		double b = (360/60 * pass_time) % 360;
 
		double ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))));
 
		System.out.println(ans);
    }
} 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();
		
		int pass_time = H*60 + M;
      	
		double a = ((double)360/60/12 * (double)pass_time) % 360;
		double b = (360/60 * pass_time) % 360;
 
		double ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))));
 
		System.out.println(ans);
    }
} 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();
		
		int pass_time = H*60 + M;
      	
		double a = ((double)360/60/12 * (double)pass_time) % 360;
		double b = (360/60 * pass_time) % 360;
 
		double ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))));
 
		System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
 
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		
		int pass_time = H*60 + M;
      	
		double a = ((double)360/60/12 * (double)pass_time) % 360;
		double b = (360/60 * pass_time) % 360;
 
		double ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))));
 
		System.out.println(ans);
    } 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 int pass_time = H*60 + M; pass_time H*60 + M H*60 H 60 M double a = ((double)360/60/12 * (double)pass_time) % 360; a ((double)360/60/12 * (double)pass_time) % 360 ((double)360/60/12 * (double)pass_time) (double)360/60/12 (double)360/60/12 (double)360 60 12 (double)pass_time 360 double b = (360/60 * pass_time) % 360; b (360/60 * pass_time) % 360 (360/60 * pass_time) 360/60 360 60 pass_time 360 double ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b)))); ans Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b)))) Math.sqrt Math A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))) B 2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))) 2 A B Math.cos(Math.toRadians(Math.abs(a-b))) Math.cos Math Math.toRadians(Math.abs(a-b)) Math.toRadians Math 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 sc = new Scanner(System.in);
 
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		
		int pass_time = H*60 + M;
      	
		double a = ((double)360/60/12 * (double)pass_time) % 360;
		double b = (360/60 * pass_time) % 360;
 
		double ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))));
 
		System.out.println(ans);
    }
} 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();
		
		int pass_time = H*60 + M;
      	
		double a = ((double)360/60/12 * (double)pass_time) % 360;
		double b = (360/60 * pass_time) % 360;
 
		double ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))));
 
		System.out.println(ans);
    }
} 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();
		
		int pass_time = H*60 + M;
      	
		double a = ((double)360/60/12 * (double)pass_time) % 360;
		double b = (360/60 * pass_time) % 360;
 
		double ans = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(a-b))));
 
		System.out.println(ans);
    }
}
