import java.util.Scanner;

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 result = 0;
		int minute = M + 60 * H;
		double radianA = 0.5 * minute;
		double radianB = 6 * minute;
		while (radianB >= 360) {
			radianB = radianB - 360;
		}
		//System.out.println(result);
		//System.out.println(radianA);
		//System.out.println(radianB);
		result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))));
		System.out.println(result);

	}

} import java.util.Scanner; Scanner 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 result = 0;
		int minute = M + 60 * H;
		double radianA = 0.5 * minute;
		double radianB = 6 * minute;
		while (radianB >= 360) {
			radianB = radianB - 360;
		}
		//System.out.println(result);
		//System.out.println(radianA);
		//System.out.println(radianB);
		result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))));
		System.out.println(result);

	}

} 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 result = 0;
		int minute = M + 60 * H;
		double radianA = 0.5 * minute;
		double radianB = 6 * minute;
		while (radianB >= 360) {
			radianB = radianB - 360;
		}
		//System.out.println(result);
		//System.out.println(radianA);
		//System.out.println(radianB);
		result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))));
		System.out.println(result);

	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double result = 0;
		int minute = M + 60 * H;
		double radianA = 0.5 * minute;
		double radianB = 6 * minute;
		while (radianB >= 360) {
			radianB = radianB - 360;
		}
		//System.out.println(result);
		//System.out.println(radianA);
		//System.out.println(radianB);
		result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))));
		System.out.println(result);

	} 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 result = 0; result 0 int minute = M + 60 * H; minute M + 60 * H M 60 * H 60 H double radianA = 0.5 * minute; radianA 0.5 * minute 0.5 minute double radianB = 6 * minute; radianB 6 * minute 6 minute while (radianB >= 360) {
			radianB = radianB - 360;
		} radianB >= 360 radianB 360 {
			radianB = radianB - 360;
		} radianB = radianB - 360 radianB radianB - 360 radianB 360 result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB)))) result Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB)))) Math.sqrt Math Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))) 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(Math.abs(radianA - radianB))) B 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))) 2 A B Math.cos(Math.toRadians(Math.abs(radianA - radianB))) Math.cos Math Math.toRadians(Math.abs(radianA - radianB)) Math.toRadians Math Math.abs(radianA - radianB) Math.abs Math radianA - radianB radianA radianB System.out.println(result) System.out.println System.out System System.out result 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 result = 0;
		int minute = M + 60 * H;
		double radianA = 0.5 * minute;
		double radianB = 6 * minute;
		while (radianB >= 360) {
			radianB = radianB - 360;
		}
		//System.out.println(result);
		//System.out.println(radianA);
		//System.out.println(radianB);
		result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))));
		System.out.println(result);

	}

} 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 result = 0;
		int minute = M + 60 * H;
		double radianA = 0.5 * minute;
		double radianB = 6 * minute;
		while (radianB >= 360) {
			radianB = radianB - 360;
		}
		//System.out.println(result);
		//System.out.println(radianA);
		//System.out.println(radianB);
		result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))));
		System.out.println(result);

	}

} Main
import java.util.Scanner;

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 result = 0;
		int minute = M + 60 * H;
		double radianA = 0.5 * minute;
		double radianB = 6 * minute;
		while (radianB >= 360) {
			radianB = radianB - 360;
		}
		//System.out.println(result);
		//System.out.println(radianA);
		//System.out.println(radianB);
		result = Math.sqrt(
				Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(Math.toRadians(Math.abs(radianA - radianB))));
		System.out.println(result);

	}

}
