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