import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double hour = h / 12  + m / 60 * (360 / 12) / 360;
		double minutes = m / 60;
		
		double angle = 360;
		if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		}
		double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle));
		
		System.out.println(Math.sqrt(ansSquare));
		sc.close();
	}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double hour = h / 12  + m / 60 * (360 / 12) / 360;
		double minutes = m / 60;
		
		double angle = 360;
		if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		}
		double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle));
		
		System.out.println(Math.sqrt(ansSquare));
		sc.close();
	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double hour = h / 12  + m / 60 * (360 / 12) / 360;
		double minutes = m / 60;
		
		double angle = 360;
		if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		}
		double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle));
		
		System.out.println(Math.sqrt(ansSquare));
		sc.close();
	} main {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double hour = h / 12  + m / 60 * (360 / 12) / 360;
		double minutes = m / 60;
		
		double angle = 360;
		if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		}
		double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle));
		
		System.out.println(Math.sqrt(ansSquare));
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double m = sc.nextDouble(); m sc.nextDouble() sc.nextDouble sc double hour = h / 12  + m / 60 * (360 / 12) / 360; hour h / 12  + m / 60 * (360 / 12) / 360 h / 12 h 12 m / 60 * (360 / 12) / 360 m / 60 * (360 / 12) m / 60 m 60 (360 / 12) 360 12 360 double minutes = m / 60; minutes m / 60 m 60 double angle = 360; angle 360 if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		} hour == 0 hour 0 {
			angle *= 1 - minutes;
		} angle *= 1 - minutes angle 1 - minutes 1 minutes if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		} minutes == 0 minutes 0 {
			angle *= 1 - hour;
		} angle *= 1 - hour angle 1 - hour 1 hour {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		} angle *= hour < minutes ? minutes - hour : hour - minutes angle hour < minutes ? minutes - hour : hour - minutes hour < minutes hour minutes minutes - hour minutes hour hour - minutes hour minutes double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle)); ansSquare Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle)) 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(angle)) b 2 * a * b * Math.cos(Math.toRadians(angle)) 2 a b Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle System.out.println(Math.sqrt(ansSquare)) System.out.println System.out System System.out Math.sqrt(ansSquare) Math.sqrt Math ansSquare sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double hour = h / 12  + m / 60 * (360 / 12) / 360;
		double minutes = m / 60;
		
		double angle = 360;
		if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		}
		double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle));
		
		System.out.println(Math.sqrt(ansSquare));
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double hour = h / 12  + m / 60 * (360 / 12) / 360;
		double minutes = m / 60;
		
		double angle = 360;
		if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		}
		double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle));
		
		System.out.println(Math.sqrt(ansSquare));
		sc.close();
	}

} Main
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double hour = h / 12  + m / 60 * (360 / 12) / 360;
		double minutes = m / 60;
		
		double angle = 360;
		if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		}
		double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle));
		
		System.out.println(Math.sqrt(ansSquare));
		sc.close();
	}

}