import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int H = sc.nextInt();
		final int M = sc.nextInt();
		sc.close();
		double omega_h = 2*Math.PI/12;
		double omega_m = 2*Math.PI/60;
		double dig_h = omega_h*H + M*Math.PI/360;
		double dig_m = omega_m*M;
		double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m)));
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int H = sc.nextInt();
		final int M = sc.nextInt();
		sc.close();
		double omega_h = 2*Math.PI/12;
		double omega_m = 2*Math.PI/60;
		double dig_h = omega_h*H + M*Math.PI/360;
		double dig_m = omega_m*M;
		double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m)));
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int H = sc.nextInt();
		final int M = sc.nextInt();
		sc.close();
		double omega_h = 2*Math.PI/12;
		double omega_m = 2*Math.PI/60;
		double dig_h = omega_h*H + M*Math.PI/360;
		double dig_m = omega_m*M;
		double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m)));
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int H = sc.nextInt();
		final int M = sc.nextInt();
		sc.close();
		double omega_h = 2*Math.PI/12;
		double omega_m = 2*Math.PI/60;
		double dig_h = omega_h*H + M*Math.PI/360;
		double dig_m = omega_m*M;
		double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m)));
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc final int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc final int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc final int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc sc.close() sc.close sc double omega_h = 2*Math.PI/12; omega_h 2*Math.PI/12 2*Math.PI 2 Math.PI Math Math.PI 12 double omega_m = 2*Math.PI/60; omega_m 2*Math.PI/60 2*Math.PI 2 Math.PI Math Math.PI 60 double dig_h = omega_h*H + M*Math.PI/360; dig_h omega_h*H + M*Math.PI/360 omega_h*H omega_h H M*Math.PI/360 M*Math.PI M Math.PI Math Math.PI 360 double dig_m = omega_m*M; dig_m omega_m*M omega_m M double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m))); ans Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m))) Math.sqrt Math A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m)) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(Math.abs(dig_h - dig_m)) B 2*A*B*Math.cos(Math.abs(dig_h - dig_m)) 2 A B Math.cos(Math.abs(dig_h - dig_m)) Math.cos Math Math.abs(dig_h - dig_m) Math.abs Math dig_h - dig_m dig_h dig_m 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 sc = new Scanner(System.in);
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int H = sc.nextInt();
		final int M = sc.nextInt();
		sc.close();
		double omega_h = 2*Math.PI/12;
		double omega_m = 2*Math.PI/60;
		double dig_h = omega_h*H + M*Math.PI/360;
		double dig_m = omega_m*M;
		double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m)));
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int H = sc.nextInt();
		final int M = sc.nextInt();
		sc.close();
		double omega_h = 2*Math.PI/12;
		double omega_m = 2*Math.PI/60;
		double dig_h = omega_h*H + M*Math.PI/360;
		double dig_m = omega_m*M;
		double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m)));
		System.out.println(ans);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int H = sc.nextInt();
		final int M = sc.nextInt();
		sc.close();
		double omega_h = 2*Math.PI/12;
		double omega_m = 2*Math.PI/60;
		double dig_h = omega_h*H + M*Math.PI/360;
		double dig_m = omega_m*M;
		double ans = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(Math.abs(dig_h - dig_m)));
		System.out.println(ans);
	}
}
