import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		


		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		


		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		


		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	} main {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		


		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double num1 = 0.5*m + 30*h; num1 0.5*m + 30*h 0.5*m 0.5 m 30*h 30 h double num2 = 6*m; num2 6*m 6 m double num3 = 0; num3 0 if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		} num1 > num2 num1 num2 {
			num3 = num1 - num2;
		} num3 = num1 - num2 num3 num1 - num2 num1 num2 if (num2 > num1){
			num3 = num2 - num1;
		} num2 > num1 num2 num1 {
			num3 = num2 - num1;
		} num3 = num2 - num1 num3 num2 - num1 num2 num1 if(num3 > 180) {
			num3 = 360- num3;
		} num3 > 180 num3 180 {
			num3 = 360- num3;
		} num3 = 360- num3 num3 360- num3 360 num3 double cos =  Math.cos(Math.toRadians(num3)); cos Math.cos(Math.toRadians(num3)) Math.cos Math Math.toRadians(num3) Math.toRadians Math num3 double c = (a*a+b*b)-(2*a*b*cos); c (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 double ans = Math.sqrt(c); ans Math.sqrt(c) Math.sqrt Math c 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) {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		


		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		


		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		


		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	}
}
