import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		
		double jisin = (double)H /12 + (double)M / 60 / 12;
		double funsin = (double)M / 60;
		
		double kakudo = Math.PI * 2 * (jisin - funsin);
		double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo));
		
		System.out.println(C);

	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		
		double jisin = (double)H /12 + (double)M / 60 / 12;
		double funsin = (double)M / 60;
		
		double kakudo = Math.PI * 2 * (jisin - funsin);
		double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo));
		
		System.out.println(C);

	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		
		double jisin = (double)H /12 + (double)M / 60 / 12;
		double funsin = (double)M / 60;
		
		double kakudo = Math.PI * 2 * (jisin - funsin);
		double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo));
		
		System.out.println(C);

	} main {
		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		
		double jisin = (double)H /12 + (double)M / 60 / 12;
		double funsin = (double)M / 60;
		
		double kakudo = Math.PI * 2 * (jisin - funsin);
		double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo));
		
		System.out.println(C);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int 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 jisin = (double)H /12 + (double)M / 60 / 12; jisin (double)H /12 + (double)M / 60 / 12 (double)H /12 (double)H 12 (double)M / 60 / 12 (double)M / 60 / 12 (double)M 60 12 double funsin = (double)M / 60; funsin (double)M / 60 (double)M 60 double kakudo = Math.PI * 2 * (jisin - funsin); kakudo Math.PI * 2 * (jisin - funsin) Math.PI * 2 * (jisin - funsin) Math.PI Math Math.PI 2 (jisin - funsin) jisin funsin double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo)); C Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo)) Math.sqrt Math A*A+B*B-2*A*B*Math.cos(kakudo) A*A+B*B A*A A A B*B B B 2*A*B*Math.cos(kakudo) B 2*A*B*Math.cos(kakudo) 2 A B Math.cos(kakudo) Math.cos Math kakudo System.out.println(C) System.out.println System.out System System.out C String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		
		double jisin = (double)H /12 + (double)M / 60 / 12;
		double funsin = (double)M / 60;
		
		double kakudo = Math.PI * 2 * (jisin - funsin);
		double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo));
		
		System.out.println(C);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		
		double jisin = (double)H /12 + (double)M / 60 / 12;
		double funsin = (double)M / 60;
		
		double kakudo = Math.PI * 2 * (jisin - funsin);
		double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo));
		
		System.out.println(C);

	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		
		double jisin = (double)H /12 + (double)M / 60 / 12;
		double funsin = (double)M / 60;
		
		double kakudo = Math.PI * 2 * (jisin - funsin);
		double C = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kakudo));
		
		System.out.println(C);

	}

}