import java.util.Scanner;

//ACならず。いちぶWA。悔しい。

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		

		double Ax;
		double Ay;
		double Bx;
		double By;
		double AB;
		double AB2;
		double sita = H/12+M/60/12-M/60;
		//System.out.println(H/12);
		//System.out.println(M/60/12);
		//System.out.println(M/60);
		double sita2;
		
		/*
		if(sita>180) {
			sita = sita -180;
		}
		if(sita<0) {
			sita = -sita;
			if(sita>180) {
				sita = sita -180;
			}
			
		}
		*/
		
				
		//System.out.println(sita);

		//AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(sita)));
		AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));
	/*	System.out.println(2*Math.PI*sita);
		System.out.println(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));


		Ax = A*Math.cos(Math.toRadians((60*H+M)/2));
		Ay = A*Math.sin(Math.toRadians((60*H+M)/2));
		Bx = B*Math.cos(Math.toRadians(6*M));
		By = B*Math.sin(Math.toRadians(6*M));

		AB2 = Math.sqrt(Math.pow(Ax-Bx, 2)+Math.pow(Ay-By, 2));
	 */
		System.out.println(AB);
		//System.out.println(AB2);


	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		

		double Ax;
		double Ay;
		double Bx;
		double By;
		double AB;
		double AB2;
		double sita = H/12+M/60/12-M/60;
		//System.out.println(H/12);
		//System.out.println(M/60/12);
		//System.out.println(M/60);
		double sita2;
		
		/*
		if(sita>180) {
			sita = sita -180;
		}
		if(sita<0) {
			sita = -sita;
			if(sita>180) {
				sita = sita -180;
			}
			
		}
		*/
		
				
		//System.out.println(sita);

		//AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(sita)));
		AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));
	/*	System.out.println(2*Math.PI*sita);
		System.out.println(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));


		Ax = A*Math.cos(Math.toRadians((60*H+M)/2));
		Ay = A*Math.sin(Math.toRadians((60*H+M)/2));
		Bx = B*Math.cos(Math.toRadians(6*M));
		By = B*Math.sin(Math.toRadians(6*M));

		AB2 = Math.sqrt(Math.pow(Ax-Bx, 2)+Math.pow(Ay-By, 2));
	 */
		System.out.println(AB);
		//System.out.println(AB2);


	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		

		double Ax;
		double Ay;
		double Bx;
		double By;
		double AB;
		double AB2;
		double sita = H/12+M/60/12-M/60;
		//System.out.println(H/12);
		//System.out.println(M/60/12);
		//System.out.println(M/60);
		double sita2;
		
		/*
		if(sita>180) {
			sita = sita -180;
		}
		if(sita<0) {
			sita = -sita;
			if(sita>180) {
				sita = sita -180;
			}
			
		}
		*/
		
				
		//System.out.println(sita);

		//AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(sita)));
		AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));
	/*	System.out.println(2*Math.PI*sita);
		System.out.println(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));


		Ax = A*Math.cos(Math.toRadians((60*H+M)/2));
		Ay = A*Math.sin(Math.toRadians((60*H+M)/2));
		Bx = B*Math.cos(Math.toRadians(6*M));
		By = B*Math.sin(Math.toRadians(6*M));

		AB2 = Math.sqrt(Math.pow(Ax-Bx, 2)+Math.pow(Ay-By, 2));
	 */
		System.out.println(AB);
		//System.out.println(AB2);


	} main {
		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		

		double Ax;
		double Ay;
		double Bx;
		double By;
		double AB;
		double AB2;
		double sita = H/12+M/60/12-M/60;
		//System.out.println(H/12);
		//System.out.println(M/60/12);
		//System.out.println(M/60);
		double sita2;
		
		/*
		if(sita>180) {
			sita = sita -180;
		}
		if(sita<0) {
			sita = -sita;
			if(sita>180) {
				sita = sita -180;
			}
			
		}
		*/
		
				
		//System.out.println(sita);

		//AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(sita)));
		AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));
	/*	System.out.println(2*Math.PI*sita);
		System.out.println(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));


		Ax = A*Math.cos(Math.toRadians((60*H+M)/2));
		Ay = A*Math.sin(Math.toRadians((60*H+M)/2));
		Bx = B*Math.cos(Math.toRadians(6*M));
		By = B*Math.sin(Math.toRadians(6*M));

		AB2 = Math.sqrt(Math.pow(Ax-Bx, 2)+Math.pow(Ay-By, 2));
	 */
		System.out.println(AB);
		//System.out.println(AB2);


	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) double A = scan.nextDouble(); A scan.nextDouble() scan.nextDouble scan double B = scan.nextDouble(); B scan.nextDouble() scan.nextDouble scan double H = scan.nextDouble(); H scan.nextDouble() scan.nextDouble scan double M = scan.nextDouble(); M scan.nextDouble() scan.nextDouble scan double Ax; Ax double Ay; Ay double Bx; Bx double By; By double AB; AB double AB2; AB2 double sita = H/12+M/60/12-M/60; sita H/12+M/60/12-M/60 H/12+M/60/12 H/12 H 12 M/60/12 M/60/12 M 60 12 M/60 M 60 double sita2; sita2 AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita)) AB Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita)) Math.sqrt Math A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita) A*A+B*B A*A A A B*B B B 2*A*B*Math.cos(2*Math.PI*sita) B 2*A*B*Math.cos(2*Math.PI*sita) 2 A B Math.cos(2*Math.PI*sita) Math.cos Math 2*Math.PI*sita 2*Math.PI*sita 2 Math.PI Math Math.PI sita System.out.println(AB) System.out.println System.out System System.out AB String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		

		double Ax;
		double Ay;
		double Bx;
		double By;
		double AB;
		double AB2;
		double sita = H/12+M/60/12-M/60;
		//System.out.println(H/12);
		//System.out.println(M/60/12);
		//System.out.println(M/60);
		double sita2;
		
		/*
		if(sita>180) {
			sita = sita -180;
		}
		if(sita<0) {
			sita = -sita;
			if(sita>180) {
				sita = sita -180;
			}
			
		}
		*/
		
				
		//System.out.println(sita);

		//AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(sita)));
		AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));
	/*	System.out.println(2*Math.PI*sita);
		System.out.println(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));


		Ax = A*Math.cos(Math.toRadians((60*H+M)/2));
		Ay = A*Math.sin(Math.toRadians((60*H+M)/2));
		Bx = B*Math.cos(Math.toRadians(6*M));
		By = B*Math.sin(Math.toRadians(6*M));

		AB2 = Math.sqrt(Math.pow(Ax-Bx, 2)+Math.pow(Ay-By, 2));
	 */
		System.out.println(AB);
		//System.out.println(AB2);


	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		

		double Ax;
		double Ay;
		double Bx;
		double By;
		double AB;
		double AB2;
		double sita = H/12+M/60/12-M/60;
		//System.out.println(H/12);
		//System.out.println(M/60/12);
		//System.out.println(M/60);
		double sita2;
		
		/*
		if(sita>180) {
			sita = sita -180;
		}
		if(sita<0) {
			sita = -sita;
			if(sita>180) {
				sita = sita -180;
			}
			
		}
		*/
		
				
		//System.out.println(sita);

		//AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(sita)));
		AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));
	/*	System.out.println(2*Math.PI*sita);
		System.out.println(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));


		Ax = A*Math.cos(Math.toRadians((60*H+M)/2));
		Ay = A*Math.sin(Math.toRadians((60*H+M)/2));
		Bx = B*Math.cos(Math.toRadians(6*M));
		By = B*Math.sin(Math.toRadians(6*M));

		AB2 = Math.sqrt(Math.pow(Ax-Bx, 2)+Math.pow(Ay-By, 2));
	 */
		System.out.println(AB);
		//System.out.println(AB2);


	}

} Main
import java.util.Scanner;

//ACならず。いちぶWA。悔しい。

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double H = scan.nextDouble();
		double M = scan.nextDouble();
		

		double Ax;
		double Ay;
		double Bx;
		double By;
		double AB;
		double AB2;
		double sita = H/12+M/60/12-M/60;
		//System.out.println(H/12);
		//System.out.println(M/60/12);
		//System.out.println(M/60);
		double sita2;
		
		/*
		if(sita>180) {
			sita = sita -180;
		}
		if(sita<0) {
			sita = -sita;
			if(sita>180) {
				sita = sita -180;
			}
			
		}
		*/
		
				
		//System.out.println(sita);

		//AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(sita)));
		AB = Math.sqrt(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));
	/*	System.out.println(2*Math.PI*sita);
		System.out.println(A*A+B*B-2*A*B*Math.cos(2*Math.PI*sita));


		Ax = A*Math.cos(Math.toRadians((60*H+M)/2));
		Ay = A*Math.sin(Math.toRadians((60*H+M)/2));
		Bx = B*Math.cos(Math.toRadians(6*M));
		By = B*Math.sin(Math.toRadians(6*M));

		AB2 = Math.sqrt(Math.pow(Ax-Bx, 2)+Math.pow(Ay-By, 2));
	 */
		System.out.println(AB);
		//System.out.println(AB2);


	}

}
