import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double H = sc.nextDouble();
		double M = sc.nextDouble();
		
		//時針と分針の角度
		double minuteHand = M / 60;
		double hourHand = (H + minuteHand) / 12;
		double angle = Math.abs(minuteHand - hourHand);

		// 結果の出力
		System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5));
		
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double H = sc.nextDouble();
		double M = sc.nextDouble();
		
		//時針と分針の角度
		double minuteHand = M / 60;
		double hourHand = (H + minuteHand) / 12;
		double angle = Math.abs(minuteHand - hourHand);

		// 結果の出力
		System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5));
		
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double H = sc.nextDouble();
		double M = sc.nextDouble();
		
		//時針と分針の角度
		double minuteHand = M / 60;
		double hourHand = (H + minuteHand) / 12;
		double angle = Math.abs(minuteHand - hourHand);

		// 結果の出力
		System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5));
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double H = sc.nextDouble();
		double M = sc.nextDouble();
		
		//時針と分針の角度
		double minuteHand = M / 60;
		double hourHand = (H + minuteHand) / 12;
		double angle = Math.abs(minuteHand - hourHand);

		// 結果の出力
		System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5));
		
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double A = sc.nextDouble(); A sc.nextDouble() sc.nextDouble sc double B = sc.nextDouble(); B sc.nextDouble() sc.nextDouble sc double H = sc.nextDouble(); H sc.nextDouble() sc.nextDouble sc double M = sc.nextDouble(); M sc.nextDouble() sc.nextDouble sc double minuteHand = M / 60; minuteHand M / 60 M 60 double hourHand = (H + minuteHand) / 12; hourHand (H + minuteHand) / 12 (H + minuteHand) H minuteHand 12 double angle = Math.abs(minuteHand - hourHand); angle Math.abs(minuteHand - hourHand) Math.abs Math minuteHand - hourHand minuteHand hourHand System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5)) System.out.println System.out System System.out Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5) Math.pow Math Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * 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(2 * Math.PI * angle)) B 2 * A * B * Math.cos(2 * Math.PI * angle) 2 A B Math.cos(2 * Math.PI * angle) Math.cos Math 2 * Math.PI * angle 2 * Math.PI * angle 2 Math.PI Math Math.PI angle 0.5 sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double H = sc.nextDouble();
		double M = sc.nextDouble();
		
		//時針と分針の角度
		double minuteHand = M / 60;
		double hourHand = (H + minuteHand) / 12;
		double angle = Math.abs(minuteHand - hourHand);

		// 結果の出力
		System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5));
		
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double H = sc.nextDouble();
		double M = sc.nextDouble();
		
		//時針と分針の角度
		double minuteHand = M / 60;
		double hourHand = (H + minuteHand) / 12;
		double angle = Math.abs(minuteHand - hourHand);

		// 結果の出力
		System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5));
		
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		double A = sc.nextDouble();
		double B = sc.nextDouble();
		double H = sc.nextDouble();
		double M = sc.nextDouble();
		
		//時針と分針の角度
		double minuteHand = M / 60;
		double hourHand = (H + minuteHand) / 12;
		double angle = Math.abs(minuteHand - hourHand);

		// 結果の出力
		System.out.println(Math.pow(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * Math.cos(2 * Math.PI * angle)), 0.5));
		
		sc.close();
	}
}
