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 hAngle = h * 30.0 + m * 0.5;
		double mAngle = m * 6.0; 
		double angle = mAngle - hAngle;
		if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		}
		double cos = Math.cos(Math.toRadians(angle));
		double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos));
		System.out.println(result);
		sc.close();
	}
} 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 hAngle = h * 30.0 + m * 0.5;
		double mAngle = m * 6.0; 
		double angle = mAngle - hAngle;
		if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		}
		double cos = Math.cos(Math.toRadians(angle));
		double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos));
		System.out.println(result);
		sc.close();
	}
} 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 hAngle = h * 30.0 + m * 0.5;
		double mAngle = m * 6.0; 
		double angle = mAngle - hAngle;
		if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		}
		double cos = Math.cos(Math.toRadians(angle));
		double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos));
		System.out.println(result);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double hAngle = h * 30.0 + m * 0.5;
		double mAngle = m * 6.0; 
		double angle = mAngle - hAngle;
		if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		}
		double cos = Math.cos(Math.toRadians(angle));
		double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos));
		System.out.println(result);
		sc.close();
	} 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 hAngle = h * 30.0 + m * 0.5; hAngle h * 30.0 + m * 0.5 h * 30.0 h 30.0 m * 0.5 m 0.5 double mAngle = m * 6.0; mAngle m * 6.0 m 6.0 double angle = mAngle - hAngle; angle mAngle - hAngle mAngle hAngle if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		} Math.abs(mAngle - hAngle) > 180 Math.abs(mAngle - hAngle) Math.abs Math mAngle - hAngle mAngle hAngle 180 {
			angle = 360.0 - angle;
		} angle = 360.0 - angle angle 360.0 - angle 360.0 angle {			
			angle *= -1;
		} angle *= -1 angle -1 1 double cos = Math.cos(Math.toRadians(angle)); cos Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos)); result Math.sqrt(a*a + b*b - (2.0*a*b*cos)) Math.sqrt Math a*a + b*b - (2.0*a*b*cos) a*a + b*b a*a a a b*b b b (2.0*a*b*cos) b 2.0*a*b*cos 2.0 a b cos System.out.println(result) System.out.println System.out System System.out result sc.close() sc.close sc 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 hAngle = h * 30.0 + m * 0.5;
		double mAngle = m * 6.0; 
		double angle = mAngle - hAngle;
		if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		}
		double cos = Math.cos(Math.toRadians(angle));
		double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos));
		System.out.println(result);
		sc.close();
	}
} 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 hAngle = h * 30.0 + m * 0.5;
		double mAngle = m * 6.0; 
		double angle = mAngle - hAngle;
		if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		}
		double cos = Math.cos(Math.toRadians(angle));
		double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos));
		System.out.println(result);
		sc.close();
	}
} 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 hAngle = h * 30.0 + m * 0.5;
		double mAngle = m * 6.0; 
		double angle = mAngle - hAngle;
		if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		}
		double cos = Math.cos(Math.toRadians(angle));
		double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos));
		System.out.println(result);
		sc.close();
	}
}
