import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	int H = sc.nextInt();
      	int M = sc.nextInt();
      	if(H == 0) H = 12;
		double H2 = (H * 60 + M) * 0.5;
        double M2 = M * 6;
      	if (M2 == 0) M2 = 360;
      	double kakudo = 0;
      	if(M2 > H2){
	      kakudo = M2 - H2;
        }
      	else{
          kakudo = H2 - M2;
    	}
      	
      	kakudo = Math.min(kakudo,360-kakudo);
      	//System.out.println(kakudo);
      	
         double cos = Math.cos(Math.toRadians(kakudo));
      	 double ans = Math.sqrt((A*A)+(B*B)-(2*A*B*cos));

         System.out.println(ans);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	int H = sc.nextInt();
      	int M = sc.nextInt();
      	if(H == 0) H = 12;
		double H2 = (H * 60 + M) * 0.5;
        double M2 = M * 6;
      	if (M2 == 0) M2 = 360;
      	double kakudo = 0;
      	if(M2 > H2){
	      kakudo = M2 - H2;
        }
      	else{
          kakudo = H2 - M2;
    	}
      	
      	kakudo = Math.min(kakudo,360-kakudo);
      	//System.out.println(kakudo);
      	
         double cos = Math.cos(Math.toRadians(kakudo));
      	 double ans = Math.sqrt((A*A)+(B*B)-(2*A*B*cos));

         System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	int H = sc.nextInt();
      	int M = sc.nextInt();
      	if(H == 0) H = 12;
		double H2 = (H * 60 + M) * 0.5;
        double M2 = M * 6;
      	if (M2 == 0) M2 = 360;
      	double kakudo = 0;
      	if(M2 > H2){
	      kakudo = M2 - H2;
        }
      	else{
          kakudo = H2 - M2;
    	}
      	
      	kakudo = Math.min(kakudo,360-kakudo);
      	//System.out.println(kakudo);
      	
         double cos = Math.cos(Math.toRadians(kakudo));
      	 double ans = Math.sqrt((A*A)+(B*B)-(2*A*B*cos));

         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();
      	if(H == 0) H = 12;
		double H2 = (H * 60 + M) * 0.5;
        double M2 = M * 6;
      	if (M2 == 0) M2 = 360;
      	double kakudo = 0;
      	if(M2 > H2){
	      kakudo = M2 - H2;
        }
      	else{
          kakudo = H2 - M2;
    	}
      	
      	kakudo = Math.min(kakudo,360-kakudo);
      	//System.out.println(kakudo);
      	
         double cos = Math.cos(Math.toRadians(kakudo));
      	 double ans = Math.sqrt((A*A)+(B*B)-(2*A*B*cos));

         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 if(H == 0) H = 12; H == 0 H 0 H = 12 H 12 double H2 = (H * 60 + M) * 0.5; H2 (H * 60 + M) * 0.5 (H * 60 + M) H * 60 H 60 M 0.5 double M2 = M * 6; M2 M * 6 M 6 if (M2 == 0) M2 = 360; M2 == 0 M2 0 M2 = 360 M2 360 double kakudo = 0; kakudo 0 if(M2 > H2){
	      kakudo = M2 - H2;
        }
      	else{
          kakudo = H2 - M2;
    	} M2 > H2 M2 H2 {
	      kakudo = M2 - H2;
        } kakudo = M2 - H2 kakudo M2 - H2 M2 H2 {
          kakudo = H2 - M2;
    	} kakudo = H2 - M2 kakudo H2 - M2 H2 M2 kakudo = Math.min(kakudo,360-kakudo) kakudo Math.min(kakudo,360-kakudo) Math.min Math kakudo 360-kakudo 360 kakudo double cos = Math.cos(Math.toRadians(kakudo)); cos Math.cos(Math.toRadians(kakudo)) Math.cos Math Math.toRadians(kakudo) Math.toRadians Math kakudo double ans = Math.sqrt((A*A)+(B*B)-(2*A*B*cos)); ans Math.sqrt((A*A)+(B*B)-(2*A*B*cos)) Math.sqrt Math (A*A)+(B*B)-(2*A*B*cos) (A*A)+(B*B) (A*A) A A (B*B) B B (2*A*B*cos) B 2*A*B*cos 2 A B cos System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	int H = sc.nextInt();
      	int M = sc.nextInt();
      	if(H == 0) H = 12;
		double H2 = (H * 60 + M) * 0.5;
        double M2 = M * 6;
      	if (M2 == 0) M2 = 360;
      	double kakudo = 0;
      	if(M2 > H2){
	      kakudo = M2 - H2;
        }
      	else{
          kakudo = H2 - M2;
    	}
      	
      	kakudo = Math.min(kakudo,360-kakudo);
      	//System.out.println(kakudo);
      	
         double cos = Math.cos(Math.toRadians(kakudo));
      	 double ans = Math.sqrt((A*A)+(B*B)-(2*A*B*cos));

         System.out.println(ans);
    }
}