
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 rad = Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

		double rsq = (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad);


		System.out.println(Math.sqrt(rsq));
	}
} 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 rad = Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

		double rsq = (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad);


		System.out.println(Math.sqrt(rsq));
	}
} 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 rad = Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

		double rsq = (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad);


		System.out.println(Math.sqrt(rsq));
	} main {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		// 時針 - 分針
		// 角度
		double rad = Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

		double rsq = (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad);


		System.out.println(Math.sqrt(rsq));
	} 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 rad = Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0); rad Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0) Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0) Math.PI Math Math.PI 2 ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0) (double)h / 12.0 + ((double)m / 60.0) / 12.0 (double)h / 12.0 (double)h 12.0 ((double)m / 60.0) / 12.0 ((double)m / 60.0) (double)m 60.0 12.0 (double)m / 60.0 (double)m 60.0 double rsq = (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad); rsq (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad) (double)(a * a + b * b) a * a a a b * b b b (double)(2 * a * b) * Math.cos(rad) (double)(2 * a * b) 2 * a * b 2 a b Math.cos(rad) Math.cos Math rad System.out.println(Math.sqrt(rsq)) System.out.println System.out System System.out Math.sqrt(rsq) Math.sqrt Math rsq 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 rad = Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

		double rsq = (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad);


		System.out.println(Math.sqrt(rsq));
	}
} 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 rad = Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

		double rsq = (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad);


		System.out.println(Math.sqrt(rsq));
	}
} 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 rad = Math.PI * 2 * ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

		double rsq = (double)(a * a + b * b) - (double)(2 * a * b) * Math.cos(rad);


		System.out.println(Math.sqrt(rsq));
	}
}