
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a, b, h, m;
		a = sc.nextInt();
		b = sc.nextInt();
		h = sc.nextInt();
		m = sc.nextInt();

		final double rad_per_min_720 = 11 * 2 * Math.PI;

		int min = h * 60 + m;
		double rad_dif = rad_per_min_720 * min / 720;

		double c_pow = a * a + b * b - 2 * a * b * Math.cos(rad_dif);
		double c = Math.sqrt(c_pow);

		System.out.println(c);
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a, b, h, m;
		a = sc.nextInt();
		b = sc.nextInt();
		h = sc.nextInt();
		m = sc.nextInt();

		final double rad_per_min_720 = 11 * 2 * Math.PI;

		int min = h * 60 + m;
		double rad_dif = rad_per_min_720 * min / 720;

		double c_pow = a * a + b * b - 2 * a * b * Math.cos(rad_dif);
		double c = Math.sqrt(c_pow);

		System.out.println(c);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a, b, h, m;
		a = sc.nextInt();
		b = sc.nextInt();
		h = sc.nextInt();
		m = sc.nextInt();

		final double rad_per_min_720 = 11 * 2 * Math.PI;

		int min = h * 60 + m;
		double rad_dif = rad_per_min_720 * min / 720;

		double c_pow = a * a + b * b - 2 * a * b * Math.cos(rad_dif);
		double c = Math.sqrt(c_pow);

		System.out.println(c);
	} main {
		Scanner sc = new Scanner(System.in);

		int a, b, h, m;
		a = sc.nextInt();
		b = sc.nextInt();
		h = sc.nextInt();
		m = sc.nextInt();

		final double rad_per_min_720 = 11 * 2 * Math.PI;

		int min = h * 60 + m;
		double rad_dif = rad_per_min_720 * min / 720;

		double c_pow = a * a + b * b - 2 * a * b * Math.cos(rad_dif);
		double c = Math.sqrt(c_pow);

		System.out.println(c);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a a b b h h m; m a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc h = sc.nextInt() h sc.nextInt() sc.nextInt sc m = sc.nextInt() m sc.nextInt() sc.nextInt sc final double rad_per_min_720 = 11 * 2 * Math.PI; rad_per_min_720 11 * 2 * Math.PI 11 * 2 * Math.PI 11 2 Math.PI Math Math.PI int min = h * 60 + m; min h * 60 + m h * 60 h 60 m double rad_dif = rad_per_min_720 * min / 720; rad_dif rad_per_min_720 * min / 720 rad_per_min_720 * min rad_per_min_720 min 720 double c_pow = a * a + b * b - 2 * a * b * Math.cos(rad_dif); c_pow a * a + b * b - 2 * a * b * Math.cos(rad_dif) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(rad_dif) b 2 * a * b * Math.cos(rad_dif) 2 a b Math.cos(rad_dif) Math.cos Math rad_dif double c = Math.sqrt(c_pow); c Math.sqrt(c_pow) Math.sqrt Math c_pow 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, b, h, m;
		a = sc.nextInt();
		b = sc.nextInt();
		h = sc.nextInt();
		m = sc.nextInt();

		final double rad_per_min_720 = 11 * 2 * Math.PI;

		int min = h * 60 + m;
		double rad_dif = rad_per_min_720 * min / 720;

		double c_pow = a * a + b * b - 2 * a * b * Math.cos(rad_dif);
		double c = Math.sqrt(c_pow);

		System.out.println(c);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a, b, h, m;
		a = sc.nextInt();
		b = sc.nextInt();
		h = sc.nextInt();
		m = sc.nextInt();

		final double rad_per_min_720 = 11 * 2 * Math.PI;

		int min = h * 60 + m;
		double rad_dif = rad_per_min_720 * min / 720;

		double c_pow = a * a + b * b - 2 * a * b * Math.cos(rad_dif);
		double c = Math.sqrt(c_pow);

		System.out.println(c);
	}

} Main

import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a, b, h, m;
		a = sc.nextInt();
		b = sc.nextInt();
		h = sc.nextInt();
		m = sc.nextInt();

		final double rad_per_min_720 = 11 * 2 * Math.PI;

		int min = h * 60 + m;
		double rad_dif = rad_per_min_720 * min / 720;

		double c_pow = a * a + b * b - 2 * a * b * Math.cos(rad_dif);
		double c = Math.sqrt(c_pow);

		System.out.println(c);
	}

}
