import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		double answer = 0.00;

		double omega = 6*M - 30*H - 0.5*M ;
//		System.out.println(omega);

		if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		}

		double radian = Math.toRadians(omega);
		answer = A*A + B*B -2*A*B*Math.cos(radian);
		answer = Math.sqrt(answer);
		System.out.println(answer);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		double answer = 0.00;

		double omega = 6*M - 30*H - 0.5*M ;
//		System.out.println(omega);

		if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		}

		double radian = Math.toRadians(omega);
		answer = A*A + B*B -2*A*B*Math.cos(radian);
		answer = Math.sqrt(answer);
		System.out.println(answer);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		double answer = 0.00;

		double omega = 6*M - 30*H - 0.5*M ;
//		System.out.println(omega);

		if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		}

		double radian = Math.toRadians(omega);
		answer = A*A + B*B -2*A*B*Math.cos(radian);
		answer = Math.sqrt(answer);
		System.out.println(answer);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		double answer = 0.00;

		double omega = 6*M - 30*H - 0.5*M ;
//		System.out.println(omega);

		if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		}

		double radian = Math.toRadians(omega);
		answer = A*A + B*B -2*A*B*Math.cos(radian);
		answer = Math.sqrt(answer);
		System.out.println(answer);
	} 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 sc.close() sc.close sc double answer = 0.00; answer 0.00 double omega = 6*M - 30*H - 0.5*M ; omega 6*M - 30*H - 0.5*M 6*M - 30*H - 0.5*M 6*M 6 M 30*H 30 H 0.5*M 0.5 M if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		} omega >= 0 omega 0 {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		} if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			} omega >= 180 omega 180 {
				omega = 360 - omega;
			} omega = 360 - omega omega 360 - omega 360 omega {
				//そのまま使えるオメガ
			} {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		} if(omega <= -180) {
				omega = 360 + omega;
			}else {

			} omega <= -180 omega -180 180 {
				omega = 360 + omega;
			} omega = 360 + omega omega 360 + omega 360 omega {

			} double radian = Math.toRadians(omega); radian Math.toRadians(omega) Math.toRadians Math omega answer = A*A + B*B -2*A*B*Math.cos(radian) answer A*A + B*B -2*A*B*Math.cos(radian) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(radian) B 2*A*B*Math.cos(radian) 2 A B Math.cos(radian) Math.cos Math radian answer = Math.sqrt(answer) answer Math.sqrt(answer) Math.sqrt Math answer System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		double answer = 0.00;

		double omega = 6*M - 30*H - 0.5*M ;
//		System.out.println(omega);

		if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		}

		double radian = Math.toRadians(omega);
		answer = A*A + B*B -2*A*B*Math.cos(radian);
		answer = Math.sqrt(answer);
		System.out.println(answer);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		double answer = 0.00;

		double omega = 6*M - 30*H - 0.5*M ;
//		System.out.println(omega);

		if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		}

		double radian = Math.toRadians(omega);
		answer = A*A + B*B -2*A*B*Math.cos(radian);
		answer = Math.sqrt(answer);
		System.out.println(answer);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();

		double answer = 0.00;

		double omega = 6*M - 30*H - 0.5*M ;
//		System.out.println(omega);

		if(omega >= 0) {
			//長針の方が進むとき
			if(omega >= 180) {
				omega = 360 - omega;
			}else {
				//そのまま使えるオメガ
			}
		}else {
			//短針の方が進むとき
			if(omega <= -180) {
				omega = 360 + omega;
			}else {

			}
		}

		double radian = Math.toRadians(omega);
		answer = A*A + B*B -2*A*B*Math.cos(radian);
		answer = Math.sqrt(answer);
		System.out.println(answer);
	}

}
