
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		//	0<=h<=11
		double h = scan.nextDouble();
		//	0<=m<=59
		double m = scan.nextDouble();

		double zishinKakudo = (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0);
		double hunshinKakudo = Math.PI * 2.0 * m / 60.0;

		double diffOfKakudo = Math.abs(zishinKakudo - hunshinKakudo);

//		if (diffOfKakudo > Math.PI) {
//			diffOfKakudo = diffOfKakudo - Math.PI;
//		}

		double L = Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo));
		double l = Math.sqrt(L);
		System.out.println(l);

	}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		//	0<=h<=11
		double h = scan.nextDouble();
		//	0<=m<=59
		double m = scan.nextDouble();

		double zishinKakudo = (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0);
		double hunshinKakudo = Math.PI * 2.0 * m / 60.0;

		double diffOfKakudo = Math.abs(zishinKakudo - hunshinKakudo);

//		if (diffOfKakudo > Math.PI) {
//			diffOfKakudo = diffOfKakudo - Math.PI;
//		}

		double L = Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo));
		double l = Math.sqrt(L);
		System.out.println(l);

	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		//	0<=h<=11
		double h = scan.nextDouble();
		//	0<=m<=59
		double m = scan.nextDouble();

		double zishinKakudo = (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0);
		double hunshinKakudo = Math.PI * 2.0 * m / 60.0;

		double diffOfKakudo = Math.abs(zishinKakudo - hunshinKakudo);

//		if (diffOfKakudo > Math.PI) {
//			diffOfKakudo = diffOfKakudo - Math.PI;
//		}

		double L = Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo));
		double l = Math.sqrt(L);
		System.out.println(l);

	} main {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		//	0<=h<=11
		double h = scan.nextDouble();
		//	0<=m<=59
		double m = scan.nextDouble();

		double zishinKakudo = (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0);
		double hunshinKakudo = Math.PI * 2.0 * m / 60.0;

		double diffOfKakudo = Math.abs(zishinKakudo - hunshinKakudo);

//		if (diffOfKakudo > Math.PI) {
//			diffOfKakudo = diffOfKakudo - Math.PI;
//		}

		double L = Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo));
		double l = Math.sqrt(L);
		System.out.println(l);

	} 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 zishinKakudo = (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0); zishinKakudo (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0) (Math.PI * h / 6.0) Math.PI * h Math.PI Math Math.PI h 6.0 (Math.PI * m / 6.0 / 60.0) Math.PI * m / 6.0 / 60.0 Math.PI * m Math.PI Math Math.PI m 6.0 60.0 double hunshinKakudo = Math.PI * 2.0 * m / 60.0; hunshinKakudo Math.PI * 2.0 * m / 60.0 Math.PI * 2.0 * m Math.PI * 2.0 * m Math.PI Math Math.PI 2.0 m 60.0 double diffOfKakudo = Math.abs(zishinKakudo - hunshinKakudo); diffOfKakudo Math.abs(zishinKakudo - hunshinKakudo) Math.abs Math zishinKakudo - hunshinKakudo zishinKakudo hunshinKakudo double L = Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo)); L Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo)) 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.0 * a * b * Math.cos(diffOfKakudo)) b 2.0 * a * b * Math.cos(diffOfKakudo) 2.0 a b Math.cos(diffOfKakudo) Math.cos Math diffOfKakudo double l = Math.sqrt(L); l Math.sqrt(L) Math.sqrt Math L System.out.println(l) System.out.println System.out System System.out l String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		//	0<=h<=11
		double h = scan.nextDouble();
		//	0<=m<=59
		double m = scan.nextDouble();

		double zishinKakudo = (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0);
		double hunshinKakudo = Math.PI * 2.0 * m / 60.0;

		double diffOfKakudo = Math.abs(zishinKakudo - hunshinKakudo);

//		if (diffOfKakudo > Math.PI) {
//			diffOfKakudo = diffOfKakudo - Math.PI;
//		}

		double L = Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo));
		double l = Math.sqrt(L);
		System.out.println(l);

	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		//	0<=h<=11
		double h = scan.nextDouble();
		//	0<=m<=59
		double m = scan.nextDouble();

		double zishinKakudo = (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0);
		double hunshinKakudo = Math.PI * 2.0 * m / 60.0;

		double diffOfKakudo = Math.abs(zishinKakudo - hunshinKakudo);

//		if (diffOfKakudo > Math.PI) {
//			diffOfKakudo = diffOfKakudo - Math.PI;
//		}

		double L = Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo));
		double l = Math.sqrt(L);
		System.out.println(l);

	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		//	0<=h<=11
		double h = scan.nextDouble();
		//	0<=m<=59
		double m = scan.nextDouble();

		double zishinKakudo = (Math.PI * h / 6.0) + (Math.PI * m / 6.0 / 60.0);
		double hunshinKakudo = Math.PI * 2.0 * m / 60.0;

		double diffOfKakudo = Math.abs(zishinKakudo - hunshinKakudo);

//		if (diffOfKakudo > Math.PI) {
//			diffOfKakudo = diffOfKakudo - Math.PI;
//		}

		double L = Math.pow(a, 2) + Math.pow(b, 2) - (2.0 * a * b * Math.cos(diffOfKakudo));
		double l = Math.sqrt(L);
		System.out.println(l);

	}

}
