import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		}
	}

} Main public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		}
	} try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		} {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc double h  = sc.nextInt(); h sc.nextInt() sc.nextInt sc double m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0; radius (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0 (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0 (h / 12 + m/(60*12) - m /60) h / 12 + m/(60*12) h / 12 h 12 m/(60*12) m (60*12) 60 12 m /60 m 60 Math.PI Math Math.PI 2.0 double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius)); ans Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius)) Math.sqrt Math Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius) 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(radius) b 2*a*b*Math.cos(radius) 2 a b Math.cos(radius) Math.cos Math radius 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){
		try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		}
	}

} public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		}
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			//a^2 = b^2 + c^2 - 2*b*c*cosA
			
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			
			double h  = sc.nextInt();
			double m = sc.nextInt();
			
			//calc radius from h and m
			double radius = (h / 12 + m/(60*12) - m /60) * Math.PI * 2.0;
//			if ( radius > Math.PI) {
//				radius = 2*Math.PI - radius;
//			}
//			System.out.println((h/12 - m / 60) * 360);
//			System.out.println(radius);
//			System.out.println(Math.pow(a, 2));
//			System.out.println(Math.pow(b, 2));
//			System.out.println(2 * a * b * Math.cos(radius));
			
			double ans = Math.sqrt(Math.pow(a, 2) + Math.pow(b,2) - 2*a*b*Math.cos(radius));
			
			System.out.println(ans);
			
		}
	}

}