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();
		sc.close();
		double shortHand = m * 6;
		double longHand = h * 30 + m * 0.5;
		double angle = Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand);
		double distance = Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle)));
		System.out.println(distance);
	}

} 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();
		sc.close();
		double shortHand = m * 6;
		double longHand = h * 30 + m * 0.5;
		double angle = Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand);
		double distance = Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle)));
		System.out.println(distance);
	}

} 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();
		sc.close();
		double shortHand = m * 6;
		double longHand = h * 30 + m * 0.5;
		double angle = Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand);
		double distance = Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle)));
		System.out.println(distance);
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		sc.close();
		double shortHand = m * 6;
		double longHand = h * 30 + m * 0.5;
		double angle = Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand);
		double distance = Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle)));
		System.out.println(distance);
	} 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 sc.close() sc.close sc double shortHand = m * 6; shortHand m * 6 m 6 double longHand = h * 30 + m * 0.5; longHand h * 30 + m * 0.5 h * 30 h 30 m * 0.5 m 0.5 double angle = Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand); angle Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand) Math.max(longHand, shortHand) Math.max Math longHand shortHand Math.min(longHand, shortHand) Math.min Math longHand shortHand double distance = Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle))); distance Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle))) Math.sqrt Math b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle)) b * b + a * a b * b b b a * a a a 2 * a * b * Math.cos(Math.toRadians(angle)) b 2 * a * b * Math.cos(Math.toRadians(angle)) 2 a b Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle System.out.println(distance) System.out.println System.out System System.out distance 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();
		sc.close();
		double shortHand = m * 6;
		double longHand = h * 30 + m * 0.5;
		double angle = Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand);
		double distance = Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle)));
		System.out.println(distance);
	}

} 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();
		sc.close();
		double shortHand = m * 6;
		double longHand = h * 30 + m * 0.5;
		double angle = Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand);
		double distance = Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle)));
		System.out.println(distance);
	}

} 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();
		sc.close();
		double shortHand = m * 6;
		double longHand = h * 30 + m * 0.5;
		double angle = Math.max(longHand, shortHand) -
				Math.min(longHand, shortHand);
		double distance = Math.sqrt(
				b * b + a * a - 2 * a * b * Math.cos(Math.toRadians(angle)));
		System.out.println(distance);
	}

}
