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 aAng = h * 30 + m * 0.5;
		double bAng = m * 6;
		System.out.println(
				Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng))))));
	}

} 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 aAng = h * 30 + m * 0.5;
		double bAng = m * 6;
		System.out.println(
				Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng))))));
	}

} 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 aAng = h * 30 + m * 0.5;
		double bAng = m * 6;
		System.out.println(
				Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng))))));
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double aAng = h * 30 + m * 0.5;
		double bAng = m * 6;
		System.out.println(
				Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng))))));
	} 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 aAng = h * 30 + m * 0.5; aAng h * 30 + m * 0.5 h * 30 h 30 m * 0.5 m 0.5 double bAng = m * 6; bAng m * 6 m 6 System.out.println(
				Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng)))))) System.out.println System.out System System.out Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng))))) Math.sqrt Math Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng)))) 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(Math.toRadians(Math.abs(360-(aAng - bAng)))) b 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng)))) 2 a b Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng)))) Math.cos Math Math.toRadians(Math.abs(360-(aAng - bAng))) Math.toRadians Math Math.abs(360-(aAng - bAng)) Math.abs Math 360-(aAng - bAng) 360 (aAng - bAng) aAng bAng 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 aAng = h * 30 + m * 0.5;
		double bAng = m * 6;
		System.out.println(
				Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng))))));
	}

} 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 aAng = h * 30 + m * 0.5;
		double bAng = m * 6;
		System.out.println(
				Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng))))));
	}

} 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 aAng = h * 30 + m * 0.5;
		double bAng = m * 6;
		System.out.println(
				Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a * b * Math.cos(Math.toRadians(Math.abs(360-(aAng - bAng))))));
	}

}
