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();

		int H_degree = 30*H;
		int M_degree = 6*M;
		double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0);
		double cos = Math.cos(radian);
		double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos);
		System.out.println(Math.sqrt(ans));

	}
} 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();

		int H_degree = 30*H;
		int M_degree = 6*M;
		double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0);
		double cos = Math.cos(radian);
		double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos);
		System.out.println(Math.sqrt(ans));

	}
} 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();

		int H_degree = 30*H;
		int M_degree = 6*M;
		double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0);
		double cos = Math.cos(radian);
		double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos);
		System.out.println(Math.sqrt(ans));

	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();

		int H_degree = 30*H;
		int M_degree = 6*M;
		double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0);
		double cos = Math.cos(radian);
		double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos);
		System.out.println(Math.sqrt(ans));

	} 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 int H_degree = 30*H; H_degree 30*H 30 H int M_degree = 6*M; M_degree 6*M 6 M double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0); radian Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0) Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0) Math.PI Math Math.PI 2 (H / 12.0 + (M / 60.0)/12.0 - M / 60.0) H / 12.0 + (M / 60.0)/12.0 H / 12.0 H 12.0 (M / 60.0)/12.0 (M / 60.0) M 60.0 12.0 M / 60.0 M 60.0 double cos = Math.cos(radian); cos Math.cos(radian) Math.cos Math radian double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos); ans Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos) 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 * cos) B 2 * A * B * cos 2 A B cos System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans 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();

		int H_degree = 30*H;
		int M_degree = 6*M;
		double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0);
		double cos = Math.cos(radian);
		double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos);
		System.out.println(Math.sqrt(ans));

	}
} 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();

		int H_degree = 30*H;
		int M_degree = 6*M;
		double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0);
		double cos = Math.cos(radian);
		double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos);
		System.out.println(Math.sqrt(ans));

	}
} 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();

		int H_degree = 30*H;
		int M_degree = 6*M;
		double radian = Math.PI * 2 * (H / 12.0 + (M / 60.0)/12.0 - M / 60.0);
		double cos = Math.cos(radian);
		double ans = Math.pow(A, 2) + Math.pow(B, 2) -(2 * A * B * cos);
		System.out.println(Math.sqrt(ans));

	}
}