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 pass_time = H*60 + M;
      	//1min =0.5°
		double digA = (0.5 * (double)pass_time) % 360;
      	//1min =6°
		double digB = (6 * pass_time) % 360;

		double C = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))));

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

		int pass_time = H*60 + M;
      	//1min =0.5°
		double digA = (0.5 * (double)pass_time) % 360;
      	//1min =6°
		double digB = (6 * pass_time) % 360;

		double C = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))));

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

		int pass_time = H*60 + M;
      	//1min =0.5°
		double digA = (0.5 * (double)pass_time) % 360;
      	//1min =6°
		double digB = (6 * pass_time) % 360;

		double C = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))));

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

		int pass_time = H*60 + M;
      	//1min =0.5°
		double digA = (0.5 * (double)pass_time) % 360;
      	//1min =6°
		double digB = (6 * pass_time) % 360;

		double C = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))));

		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 int pass_time = H*60 + M; pass_time H*60 + M H*60 H 60 M double digA = (0.5 * (double)pass_time) % 360; digA (0.5 * (double)pass_time) % 360 (0.5 * (double)pass_time) 0.5 (double)pass_time 360 double digB = (6 * pass_time) % 360; digB (6 * pass_time) % 360 (6 * pass_time) 6 pass_time 360 double C = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB)))); C Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB)))) Math.sqrt Math A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))) B 2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))) 2 A B Math.cos(Math.toRadians(Math.abs(digA-digB))) Math.cos Math Math.toRadians(Math.abs(digA-digB)) Math.toRadians Math Math.abs(digA-digB) Math.abs Math digA-digB digA digB 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();

		int pass_time = H*60 + M;
      	//1min =0.5°
		double digA = (0.5 * (double)pass_time) % 360;
      	//1min =6°
		double digB = (6 * pass_time) % 360;

		double C = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))));

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

		int pass_time = H*60 + M;
      	//1min =0.5°
		double digA = (0.5 * (double)pass_time) % 360;
      	//1min =6°
		double digB = (6 * pass_time) % 360;

		double C = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))));

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

		int pass_time = H*60 + M;
      	//1min =0.5°
		double digA = (0.5 * (double)pass_time) % 360;
      	//1min =6°
		double digB = (6 * pass_time) % 360;

		double C = Math.sqrt(A*A + B*B -2*A*B*Math.cos(Math.toRadians(Math.abs(digA-digB))));

		System.out.println(C);

	}
}