import java. util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

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

		double s = (h*60+m)*(0.5);
		double l = m*6;

		double kaku = s-l;

		if(kaku>180) {
			kaku = 360-kaku;
		}

		double cos = Math.cos(Math.toRadians(kaku));

		double result2 = a*a + b*b - 2*a*b*cos;

		double result = Math.sqrt(result2);

		System.out.println(result);

	}

} import java. util.Scanner; Scanner java. util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

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

		double s = (h*60+m)*(0.5);
		double l = m*6;

		double kaku = s-l;

		if(kaku>180) {
			kaku = 360-kaku;
		}

		double cos = Math.cos(Math.toRadians(kaku));

		double result2 = a*a + b*b - 2*a*b*cos;

		double result = Math.sqrt(result2);

		System.out.println(result);

	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

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

		double s = (h*60+m)*(0.5);
		double l = m*6;

		double kaku = s-l;

		if(kaku>180) {
			kaku = 360-kaku;
		}

		double cos = Math.cos(Math.toRadians(kaku));

		double result2 = a*a + b*b - 2*a*b*cos;

		double result = Math.sqrt(result2);

		System.out.println(result);

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

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

		double s = (h*60+m)*(0.5);
		double l = m*6;

		double kaku = s-l;

		if(kaku>180) {
			kaku = 360-kaku;
		}

		double cos = Math.cos(Math.toRadians(kaku));

		double result2 = a*a + b*b - 2*a*b*cos;

		double result = Math.sqrt(result2);

		System.out.println(result);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan double s = (h*60+m)*(0.5); s (h*60+m)*(0.5) (h*60+m) h*60 h 60 m (0.5) double l = m*6; l m*6 m 6 double kaku = s-l; kaku s-l s l if(kaku>180) {
			kaku = 360-kaku;
		} kaku>180 kaku 180 {
			kaku = 360-kaku;
		} kaku = 360-kaku kaku 360-kaku 360 kaku double cos = Math.cos(Math.toRadians(kaku)); cos Math.cos(Math.toRadians(kaku)) Math.cos Math Math.toRadians(kaku) Math.toRadians Math kaku double result2 = a*a + b*b - 2*a*b*cos; result2 a*a + b*b - 2*a*b*cos a*a + b*b a*a a a b*b b b 2*a*b*cos b 2*a*b*cos 2 a b cos double result = Math.sqrt(result2); result Math.sqrt(result2) Math.sqrt Math result2 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

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

		double s = (h*60+m)*(0.5);
		double l = m*6;

		double kaku = s-l;

		if(kaku>180) {
			kaku = 360-kaku;
		}

		double cos = Math.cos(Math.toRadians(kaku));

		double result2 = a*a + b*b - 2*a*b*cos;

		double result = Math.sqrt(result2);

		System.out.println(result);

	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

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

		double s = (h*60+m)*(0.5);
		double l = m*6;

		double kaku = s-l;

		if(kaku>180) {
			kaku = 360-kaku;
		}

		double cos = Math.cos(Math.toRadians(kaku));

		double result2 = a*a + b*b - 2*a*b*cos;

		double result = Math.sqrt(result2);

		System.out.println(result);

	}

} Main
import java. util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

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

		double s = (h*60+m)*(0.5);
		double l = m*6;

		double kaku = s-l;

		if(kaku>180) {
			kaku = 360-kaku;
		}

		double cos = Math.cos(Math.toRadians(kaku));

		double result2 = a*a + b*b - 2*a*b*cos;

		double result = Math.sqrt(result2);

		System.out.println(result);

	}

}
