import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		}
	}
} Main public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		}
	} main {
		try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		}
	} try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		} {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner int H = scanner.nextInt(); H scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI; sita ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) (double)H / 12 + (double)M / 12 / 60 (double)H / 12 (double)H 12 (double)M / 12 / 60 (double)M / 12 / 60 (double)M 12 60 (double)M / 60 (double)M 60 2 Math.PI Math Math.PI sita = sita < 0 ? -(double)sita : sita sita sita < 0 ? -(double)sita : sita sita < 0 sita 0 -(double)sita (double)sita sita double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita)))); answer Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita)))) Math.sqrt Math (double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))) 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 (double)((double)(2 * A * B) * Math.cos(sita)) (double)(2 * A * B) 2 * A * B 2 A B Math.cos(sita) Math.cos Math sita System.out.print(answer) System.out.print System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		}
	}
} public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			int H = scanner.nextInt();
			int M = scanner.nextInt();

			double sita = ((double)H / 12 + (double)M / 12 / 60 - (double)M / 60) * 2 * Math.PI;
			sita = sita < 0 ? -(double)sita : sita;
			double answer = Math.sqrt((double)(Math.pow(A, 2) + Math.pow(B, 2) - (double)((double)(2 * A * B) * Math.cos(sita))));
			System.out.print(answer);
		}
	}
}