import java.util.Scanner;

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

		double a = scan.nextInt();//短針の長さ
		double b = scan.nextInt();//長針の長さ
		int h = scan.nextInt();//時間
		int m = scan.nextInt();//分
		double a_w = (30 * h) + (0.5 * m);//短針の角度
		double b_w = 6 * m;//長針の角度
		double w = 0;
		double ans = 0;

		if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		}

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

		ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))));

		System.out.printf("%.20f" , ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		double a = scan.nextInt();//短針の長さ
		double b = scan.nextInt();//長針の長さ
		int h = scan.nextInt();//時間
		int m = scan.nextInt();//分
		double a_w = (30 * h) + (0.5 * m);//短針の角度
		double b_w = 6 * m;//長針の角度
		double w = 0;
		double ans = 0;

		if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		}

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

		ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))));

		System.out.printf("%.20f" , ans);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		double a = scan.nextInt();//短針の長さ
		double b = scan.nextInt();//長針の長さ
		int h = scan.nextInt();//時間
		int m = scan.nextInt();//分
		double a_w = (30 * h) + (0.5 * m);//短針の角度
		double b_w = 6 * m;//長針の角度
		double w = 0;
		double ans = 0;

		if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		}

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

		ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))));

		System.out.printf("%.20f" , ans);
	} main {
		Scanner scan = new Scanner(System.in);

		double a = scan.nextInt();//短針の長さ
		double b = scan.nextInt();//長針の長さ
		int h = scan.nextInt();//時間
		int m = scan.nextInt();//分
		double a_w = (30 * h) + (0.5 * m);//短針の角度
		double b_w = 6 * m;//長針の角度
		double w = 0;
		double ans = 0;

		if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		}

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

		ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))));

		System.out.printf("%.20f" , ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) double a = scan.nextInt(); a scan.nextInt() scan.nextInt scan double 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 a_w = (30 * h) + (0.5 * m); a_w (30 * h) + (0.5 * m) (30 * h) 30 h (0.5 * m) 0.5 m double b_w = 6 * m; b_w 6 * m 6 m double w = 0; w 0 double ans = 0; ans 0 if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		} a_w >= b_w a_w b_w {
			w = a_w - b_w;
		} w = a_w - b_w w a_w - b_w a_w b_w {
			w = b_w - a_w;
		} w = b_w - a_w w b_w - a_w b_w a_w if(w > 180) {
			w = 360 - w;
		} w > 180 w 180 {
			w = 360 - w;
		} w = 360 - w w 360 - w 360 w ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w)))) ans Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w)))) Math.sqrt Math Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))) 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(w))) b 2 * a * b * Math.cos(Math.toRadians(w)) 2 a b Math.cos(Math.toRadians(w)) Math.cos Math Math.toRadians(w) Math.toRadians Math w System.out.printf("%.20f" , ans) System.out.printf System.out System System.out "%.20f" ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		double a = scan.nextInt();//短針の長さ
		double b = scan.nextInt();//長針の長さ
		int h = scan.nextInt();//時間
		int m = scan.nextInt();//分
		double a_w = (30 * h) + (0.5 * m);//短針の角度
		double b_w = 6 * m;//長針の角度
		double w = 0;
		double ans = 0;

		if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		}

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

		ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))));

		System.out.printf("%.20f" , ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		double a = scan.nextInt();//短針の長さ
		double b = scan.nextInt();//長針の長さ
		int h = scan.nextInt();//時間
		int m = scan.nextInt();//分
		double a_w = (30 * h) + (0.5 * m);//短針の角度
		double b_w = 6 * m;//長針の角度
		double w = 0;
		double ans = 0;

		if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		}

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

		ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))));

		System.out.printf("%.20f" , ans);
	}
} Main
import java.util.Scanner;

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

		double a = scan.nextInt();//短針の長さ
		double b = scan.nextInt();//長針の長さ
		int h = scan.nextInt();//時間
		int m = scan.nextInt();//分
		double a_w = (30 * h) + (0.5 * m);//短針の角度
		double b_w = 6 * m;//長針の角度
		double w = 0;
		double ans = 0;

		if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		}

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

		ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))));

		System.out.printf("%.20f" , ans);
	}
}
