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 h_angle = h * 30 + (m * 0.5);
		double m_angle = m * 6;

		double diff_angle = Math.abs(h_angle - m_angle);
		if (diff_angle == 180.0) {
			System.out.println(a + b);
		} else if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		}
	}

} 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 h_angle = h * 30 + (m * 0.5);
		double m_angle = m * 6;

		double diff_angle = Math.abs(h_angle - m_angle);
		if (diff_angle == 180.0) {
			System.out.println(a + b);
		} else if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		}
	}

} 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 h_angle = h * 30 + (m * 0.5);
		double m_angle = m * 6;

		double diff_angle = Math.abs(h_angle - m_angle);
		if (diff_angle == 180.0) {
			System.out.println(a + b);
		} else if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		}
	} main {
		Scanner sc = new Scanner(System.in);

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

		double h_angle = h * 30 + (m * 0.5);
		double m_angle = m * 6;

		double diff_angle = Math.abs(h_angle - m_angle);
		if (diff_angle == 180.0) {
			System.out.println(a + b);
		} else if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		}
	} 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 h_angle = h * 30 + (m * 0.5); h_angle h * 30 + (m * 0.5) h * 30 h 30 (m * 0.5) m 0.5 double m_angle = m * 6; m_angle m * 6 m 6 double diff_angle = Math.abs(h_angle - m_angle); diff_angle Math.abs(h_angle - m_angle) Math.abs Math h_angle - m_angle h_angle m_angle if (diff_angle == 180.0) {
			System.out.println(a + b);
		} else if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		} diff_angle == 180.0 diff_angle 180.0 {
			System.out.println(a + b);
		} System.out.println(a + b) System.out.println System.out System System.out a + b a b if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		} diff_angle == 0.0 diff_angle 0.0 {
			System.out.println(Math.abs(a - b));
		} System.out.println(Math.abs(a - b)) System.out.println System.out System System.out Math.abs(a - b) Math.abs Math a - b a b {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		} double cosC = Math.cos(Math.toRadians(diff_angle)); cosC Math.cos(Math.toRadians(diff_angle)) Math.cos Math Math.toRadians(diff_angle) Math.toRadians Math diff_angle double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC); length Math.sqrt(a * a + b * b - 2 * a * b * cosC) Math.sqrt Math a * a + b * b - 2 * a * b * cosC a * a + b * b a * a a a b * b b b 2 * a * b * cosC b 2 * a * b * cosC 2 a b cosC System.out.println(length) System.out.println System.out System System.out length 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 h_angle = h * 30 + (m * 0.5);
		double m_angle = m * 6;

		double diff_angle = Math.abs(h_angle - m_angle);
		if (diff_angle == 180.0) {
			System.out.println(a + b);
		} else if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		}
	}

} 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 h_angle = h * 30 + (m * 0.5);
		double m_angle = m * 6;

		double diff_angle = Math.abs(h_angle - m_angle);
		if (diff_angle == 180.0) {
			System.out.println(a + b);
		} else if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		}
	}

} 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 h_angle = h * 30 + (m * 0.5);
		double m_angle = m * 6;

		double diff_angle = Math.abs(h_angle - m_angle);
		if (diff_angle == 180.0) {
			System.out.println(a + b);
		} else if (diff_angle == 0.0) {
			System.out.println(Math.abs(a - b));
		} else {
			double cosC = Math.cos(Math.toRadians(diff_angle));
			double length = Math.sqrt(a * a + b * b - 2 * a * b * cosC);
			System.out.println(length);
		}
	}

}
