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 C = 0;
		double m = M*6;
		double h = H*30 + m/12;
		sc.close();

		double k = Math.abs(h-m);

		double K = Math.cos(Math.toRadians(k));

		C = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K);

		System.out.println(C);
	}

} 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 C = 0;
		double m = M*6;
		double h = H*30 + m/12;
		sc.close();

		double k = Math.abs(h-m);

		double K = Math.cos(Math.toRadians(k));

		C = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K);

		System.out.println(C);
	}

} 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 C = 0;
		double m = M*6;
		double h = H*30 + m/12;
		sc.close();

		double k = Math.abs(h-m);

		double K = Math.cos(Math.toRadians(k));

		C = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K);

		System.out.println(C);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		double C = 0;
		double m = M*6;
		double h = H*30 + m/12;
		sc.close();

		double k = Math.abs(h-m);

		double K = Math.cos(Math.toRadians(k));

		C = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K);

		System.out.println(C);
	} 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 C = 0; C 0 double m = M*6; m M*6 M 6 double h = H*30 + m/12; h H*30 + m/12 H*30 H 30 m/12 m 12 sc.close() sc.close sc double k = Math.abs(h-m); k Math.abs(h-m) Math.abs Math h-m h m double K = Math.cos(Math.toRadians(k)); K Math.cos(Math.toRadians(k)) Math.cos Math Math.toRadians(k) Math.toRadians Math k C = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K) C Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K) Math.sqrt Math Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K 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*K B 2*A*B*K 2 A B K System.out.println(C) System.out.println System.out System System.out C 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 C = 0;
		double m = M*6;
		double h = H*30 + m/12;
		sc.close();

		double k = Math.abs(h-m);

		double K = Math.cos(Math.toRadians(k));

		C = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K);

		System.out.println(C);
	}

} 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 C = 0;
		double m = M*6;
		double h = H*30 + m/12;
		sc.close();

		double k = Math.abs(h-m);

		double K = Math.cos(Math.toRadians(k));

		C = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K);

		System.out.println(C);
	}

} 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 C = 0;
		double m = M*6;
		double h = H*30 + m/12;
		sc.close();

		double k = Math.abs(h-m);

		double K = Math.cos(Math.toRadians(k));

		C = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*K);

		System.out.println(C);
	}

}