
import java.util.Scanner;
//import java.math.*;

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

		// calculate angle
		double diff = Math.abs(h * 30 + m * 0.5 - m * 6);
		double angle = 0;
		if (diff == 180) {
			System.out.println(a + b);
		} else if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		}

	}

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

		// calculate angle
		double diff = Math.abs(h * 30 + m * 0.5 - m * 6);
		double angle = 0;
		if (diff == 180) {
			System.out.println(a + b);
		} else if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		}

	}

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

		// calculate angle
		double diff = Math.abs(h * 30 + m * 0.5 - m * 6);
		double angle = 0;
		if (diff == 180) {
			System.out.println(a + b);
		} else if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		}

	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		// calculate angle
		double diff = Math.abs(h * 30 + m * 0.5 - m * 6);
		double angle = 0;
		if (diff == 180) {
			System.out.println(a + b);
		} else if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		}

	} 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 diff = Math.abs(h * 30 + m * 0.5 - m * 6); diff Math.abs(h * 30 + m * 0.5 - m * 6) Math.abs Math h * 30 + m * 0.5 - m * 6 h * 30 + m * 0.5 h * 30 h 30 m * 0.5 m 0.5 m * 6 m 6 double angle = 0; angle 0 if (diff == 180) {
			System.out.println(a + b);
		} else if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} diff == 180 diff 180 {
			System.out.println(a + b);
		} System.out.println(a + b) System.out.println System.out System System.out a + b a b if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} diff < 180 diff 180 {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} angle = Math.toRadians(diff) angle Math.toRadians(diff) Math.toRadians Math diff double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle); ans Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle) 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 * Math.cos(angle) b 2 * a * b * Math.cos(angle) 2 a b Math.cos(angle) Math.cos Math angle System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans sc.close() sc.close sc {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} angle = Math.toRadians(360 - diff) angle Math.toRadians(360 - diff) Math.toRadians Math 360 - diff 360 diff double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle); ans Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle) 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 * Math.cos(angle) b 2 * a * b * Math.cos(angle) 2 a b Math.cos(angle) Math.cos Math angle System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans sc.close() sc.close sc 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();

		// calculate angle
		double diff = Math.abs(h * 30 + m * 0.5 - m * 6);
		double angle = 0;
		if (diff == 180) {
			System.out.println(a + b);
		} else if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		}

	}

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

		// calculate angle
		double diff = Math.abs(h * 30 + m * 0.5 - m * 6);
		double angle = 0;
		if (diff == 180) {
			System.out.println(a + b);
		} else if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		}

	}

} Main

import java.util.Scanner;
//import java.math.*;

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

		// calculate angle
		double diff = Math.abs(h * 30 + m * 0.5 - m * 6);
		double angle = 0;
		if (diff == 180) {
			System.out.println(a + b);
		} else if (diff < 180) {
			angle = Math.toRadians(diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		} else {
			angle = Math.toRadians(360 - diff);
			// calculate distance
			double ans = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(angle);
			System.out.println(Math.sqrt(ans));
			sc.close();
		}

	}

}
