import java.util.*;

public 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();
		
		double akakudo = (H * 30 + M * 0.5) % 360 ;
		double bkakudo = (M * 6) % 360 ;
		double ckakudo = Math.abs(akakudo-bkakudo);
		
		if (ckakudo>=180){
			ckakudo = 360 - ckakudo; 
		} else  {
			ckakudo = ckakudo;
		}
		
		double a = (double) A;
		double b = (double) B;
		
		double c = Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) )));
		System.out.println(c);
		
		
	}
} import java.util.*; util.* java public 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();
		
		double akakudo = (H * 30 + M * 0.5) % 360 ;
		double bkakudo = (M * 6) % 360 ;
		double ckakudo = Math.abs(akakudo-bkakudo);
		
		if (ckakudo>=180){
			ckakudo = 360 - ckakudo; 
		} else  {
			ckakudo = ckakudo;
		}
		
		double a = (double) A;
		double b = (double) B;
		
		double c = Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) )));
		System.out.println(c);
		
		
	}
} 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();
		
		double akakudo = (H * 30 + M * 0.5) % 360 ;
		double bkakudo = (M * 6) % 360 ;
		double ckakudo = Math.abs(akakudo-bkakudo);
		
		if (ckakudo>=180){
			ckakudo = 360 - ckakudo; 
		} else  {
			ckakudo = ckakudo;
		}
		
		double a = (double) A;
		double b = (double) B;
		
		double c = Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) )));
		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 akakudo = (H * 30 + M * 0.5) % 360 ;
		double bkakudo = (M * 6) % 360 ;
		double ckakudo = Math.abs(akakudo-bkakudo);
		
		if (ckakudo>=180){
			ckakudo = 360 - ckakudo; 
		} else  {
			ckakudo = ckakudo;
		}
		
		double a = (double) A;
		double b = (double) B;
		
		double c = Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) )));
		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 akakudo = (H * 30 + M * 0.5) % 360 ; akakudo (H * 30 + M * 0.5) % 360 (H * 30 + M * 0.5) H * 30 H 30 M * 0.5 M 0.5 360 double bkakudo = (M * 6) % 360 ; bkakudo (M * 6) % 360 (M * 6) M 6 360 double ckakudo = Math.abs(akakudo-bkakudo); ckakudo Math.abs(akakudo-bkakudo) Math.abs Math akakudo-bkakudo akakudo bkakudo if (ckakudo>=180){
			ckakudo = 360 - ckakudo; 
		} else  {
			ckakudo = ckakudo;
		} ckakudo>=180 ckakudo 180 {
			ckakudo = 360 - ckakudo; 
		} ckakudo = 360 - ckakudo ckakudo 360 - ckakudo 360 ckakudo {
			ckakudo = ckakudo;
		} ckakudo = ckakudo ckakudo ckakudo double a = (double) A; a (double) A double b = (double) B; b (double) B double c = Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) ))); c Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) ))) Math.sqrt Math ( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) )) Math.pow(a,2) + Math.pow(b,2) Math.pow(a,2) Math.pow Math a 2 Math.pow(b,2) Math.pow Math b 2 2*a*b*(Math.cos(Math.toRadians(ckakudo)) ) b 2*a*b*(Math.cos(Math.toRadians(ckakudo)) ) 2 a b (Math.cos(Math.toRadians(ckakudo)) ) Math.cos Math Math.toRadians(ckakudo) Math.toRadians Math ckakudo 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){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		
		double akakudo = (H * 30 + M * 0.5) % 360 ;
		double bkakudo = (M * 6) % 360 ;
		double ckakudo = Math.abs(akakudo-bkakudo);
		
		if (ckakudo>=180){
			ckakudo = 360 - ckakudo; 
		} else  {
			ckakudo = ckakudo;
		}
		
		double a = (double) A;
		double b = (double) B;
		
		double c = Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) )));
		System.out.println(c);
		
		
	}
} public 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();
		
		double akakudo = (H * 30 + M * 0.5) % 360 ;
		double bkakudo = (M * 6) % 360 ;
		double ckakudo = Math.abs(akakudo-bkakudo);
		
		if (ckakudo>=180){
			ckakudo = 360 - ckakudo; 
		} else  {
			ckakudo = ckakudo;
		}
		
		double a = (double) A;
		double b = (double) B;
		
		double c = Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) )));
		System.out.println(c);
		
		
	}
} Main
import java.util.*;

public 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();
		
		double akakudo = (H * 30 + M * 0.5) % 360 ;
		double bkakudo = (M * 6) % 360 ;
		double ckakudo = Math.abs(akakudo-bkakudo);
		
		if (ckakudo>=180){
			ckakudo = 360 - ckakudo; 
		} else  {
			ckakudo = ckakudo;
		}
		
		double a = (double) A;
		double b = (double) B;
		
		double c = Math.sqrt(( Math.pow(a,2) + Math.pow(b,2) - 2*a*b*(Math.cos(Math.toRadians(ckakudo)) )));
		System.out.println(c);
		
		
	}
}