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 p = h*30 + m*0.5;
		double q = m*6;
		
		double ans = 0;
		double th = Math.abs(p-q);
		double th1 = 360 - Math.abs((p-q));
		if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		}
		double result = Math.cos(Math.toRadians(ans));
		double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result;
		double x = Math.sqrt(line);
		System.out.println(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 p = h*30 + m*0.5;
		double q = m*6;
		
		double ans = 0;
		double th = Math.abs(p-q);
		double th1 = 360 - Math.abs((p-q));
		if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		}
		double result = Math.cos(Math.toRadians(ans));
		double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result;
		double x = Math.sqrt(line);
		System.out.println(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 p = h*30 + m*0.5;
		double q = m*6;
		
		double ans = 0;
		double th = Math.abs(p-q);
		double th1 = 360 - Math.abs((p-q));
		if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		}
		double result = Math.cos(Math.toRadians(ans));
		double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result;
		double x = Math.sqrt(line);
		System.out.println(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 p = h*30 + m*0.5;
		double q = m*6;
		
		double ans = 0;
		double th = Math.abs(p-q);
		double th1 = 360 - Math.abs((p-q));
		if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		}
		double result = Math.cos(Math.toRadians(ans));
		double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result;
		double x = Math.sqrt(line);
		System.out.println(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 p = h*30 + m*0.5; p h*30 + m*0.5 h*30 h 30 m*0.5 m 0.5 double q = m*6; q m*6 m 6 double ans = 0; ans 0 double th = Math.abs(p-q); th Math.abs(p-q) Math.abs Math p-q p q double th1 = 360 - Math.abs((p-q)); th1 360 - Math.abs((p-q)) 360 Math.abs((p-q)) Math.abs Math (p-q) p q if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		} th<th1 th th1 {
			ans = th;
		} ans = th ans th {
			ans = th1;
		} ans = th1 ans th1 double result = Math.cos(Math.toRadians(ans)); result Math.cos(Math.toRadians(ans)) Math.cos Math Math.toRadians(ans) Math.toRadians Math ans double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result; line Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result 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*result b 2*a*b*result 2 a b result double x = Math.sqrt(line); x Math.sqrt(line) Math.sqrt Math line System.out.println(x) System.out.println System.out System System.out 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 p = h*30 + m*0.5;
		double q = m*6;
		
		double ans = 0;
		double th = Math.abs(p-q);
		double th1 = 360 - Math.abs((p-q));
		if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		}
		double result = Math.cos(Math.toRadians(ans));
		double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result;
		double x = Math.sqrt(line);
		System.out.println(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 p = h*30 + m*0.5;
		double q = m*6;
		
		double ans = 0;
		double th = Math.abs(p-q);
		double th1 = 360 - Math.abs((p-q));
		if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		}
		double result = Math.cos(Math.toRadians(ans));
		double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result;
		double x = Math.sqrt(line);
		System.out.println(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 p = h*30 + m*0.5;
		double q = m*6;
		
		double ans = 0;
		double th = Math.abs(p-q);
		double th1 = 360 - Math.abs((p-q));
		if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		}
		double result = Math.cos(Math.toRadians(ans));
		double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result;
		double x = Math.sqrt(line);
		System.out.println(x);
	}

}
