import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A, B, H, M;

		A = Integer.parseInt(in.next());
		B = Integer.parseInt(in.next());
		H = Integer.parseInt(in.next());
		M = Integer.parseInt(in.next());
		double pi = Math.PI;

		double alpha = 2 * pi * H / 12 + 2 * pi * M / 720;
		double beta = 2 * pi * M / 60;

		double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta));
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A, B, H, M;

		A = Integer.parseInt(in.next());
		B = Integer.parseInt(in.next());
		H = Integer.parseInt(in.next());
		M = Integer.parseInt(in.next());
		double pi = Math.PI;

		double alpha = 2 * pi * H / 12 + 2 * pi * M / 720;
		double beta = 2 * pi * M / 60;

		double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta));
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A, B, H, M;

		A = Integer.parseInt(in.next());
		B = Integer.parseInt(in.next());
		H = Integer.parseInt(in.next());
		M = Integer.parseInt(in.next());
		double pi = Math.PI;

		double alpha = 2 * pi * H / 12 + 2 * pi * M / 720;
		double beta = 2 * pi * M / 60;

		double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta));
		System.out.println(ans);
	} main {
		Scanner in = new Scanner(System.in);
		int A, B, H, M;

		A = Integer.parseInt(in.next());
		B = Integer.parseInt(in.next());
		H = Integer.parseInt(in.next());
		M = Integer.parseInt(in.next());
		double pi = Math.PI;

		double alpha = 2 * pi * H / 12 + 2 * pi * M / 720;
		double beta = 2 * pi * M / 60;

		double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta));
		System.out.println(ans);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int A A B B H H M; M A = Integer.parseInt(in.next()) A Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in B = Integer.parseInt(in.next()) B Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in H = Integer.parseInt(in.next()) H Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in M = Integer.parseInt(in.next()) M Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in double pi = Math.PI; pi Math.PI Math Math.PI double alpha = 2 * pi * H / 12 + 2 * pi * M / 720; alpha 2 * pi * H / 12 + 2 * pi * M / 720 2 * pi * H / 12 2 * pi * H 2 * pi * H 2 pi H 12 2 * pi * M / 720 2 * pi * M 2 * pi * M 2 pi M 720 double beta = 2 * pi * M / 60; beta 2 * pi * M / 60 2 * pi * M 2 * pi * M 2 pi M 60 double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta)); ans Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta)) Math.sqrt Math Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta) 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(alpha - beta) B 2 * A * B * Math.cos(alpha - beta) 2 A B Math.cos(alpha - beta) Math.cos Math alpha - beta alpha beta 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 in = new Scanner(System.in);
		int A, B, H, M;

		A = Integer.parseInt(in.next());
		B = Integer.parseInt(in.next());
		H = Integer.parseInt(in.next());
		M = Integer.parseInt(in.next());
		double pi = Math.PI;

		double alpha = 2 * pi * H / 12 + 2 * pi * M / 720;
		double beta = 2 * pi * M / 60;

		double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta));
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A, B, H, M;

		A = Integer.parseInt(in.next());
		B = Integer.parseInt(in.next());
		H = Integer.parseInt(in.next());
		M = Integer.parseInt(in.next());
		double pi = Math.PI;

		double alpha = 2 * pi * H / 12 + 2 * pi * M / 720;
		double beta = 2 * pi * M / 60;

		double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta));
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A, B, H, M;

		A = Integer.parseInt(in.next());
		B = Integer.parseInt(in.next());
		H = Integer.parseInt(in.next());
		M = Integer.parseInt(in.next());
		double pi = Math.PI;

		double alpha = 2 * pi * H / 12 + 2 * pi * M / 720;
		double beta = 2 * pi * M / 60;

		double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(alpha - beta));
		System.out.println(ans);
	}
}
