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 deg = 0;
		deg = (30 * h) + (0.5 * m) - (6 * m);

		// a2 = b2 + c2 - 2bcCOSdeg
		double ans = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg))));
		System.out.println(ans);

		scan.close();

	}

} 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 deg = 0;
		deg = (30 * h) + (0.5 * m) - (6 * m);

		// a2 = b2 + c2 - 2bcCOSdeg
		double ans = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg))));
		System.out.println(ans);

		scan.close();

	}

} 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 deg = 0;
		deg = (30 * h) + (0.5 * m) - (6 * m);

		// a2 = b2 + c2 - 2bcCOSdeg
		double ans = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg))));
		System.out.println(ans);

		scan.close();

	} main {

		Scanner scan = new Scanner(System.in);

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

		// 中心角
		double deg = 0;
		deg = (30 * h) + (0.5 * m) - (6 * m);

		// a2 = b2 + c2 - 2bcCOSdeg
		double ans = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg))));
		System.out.println(ans);

		scan.close();

	} 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 deg = 0; deg 0 deg = (30 * h) + (0.5 * m) - (6 * m) deg (30 * h) + (0.5 * m) - (6 * m) (30 * h) + (0.5 * m) (30 * h) 30 h (0.5 * m) 0.5 m (6 * m) 6 m double ans = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg)))); ans Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg)))) Math.sqrt Math (a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg))) (a*a) + (b*b) (a*a) a a (b*b) b b (2*a*b*Math.cos(Math.toRadians(deg))) b 2*a*b*Math.cos(Math.toRadians(deg)) 2 a b Math.cos(Math.toRadians(deg)) Math.cos Math Math.toRadians(deg) Math.toRadians Math deg System.out.println(ans) System.out.println System.out System System.out ans scan.close() scan.close scan 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 deg = 0;
		deg = (30 * h) + (0.5 * m) - (6 * m);

		// a2 = b2 + c2 - 2bcCOSdeg
		double ans = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg))));
		System.out.println(ans);

		scan.close();

	}

} 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 deg = 0;
		deg = (30 * h) + (0.5 * m) - (6 * m);

		// a2 = b2 + c2 - 2bcCOSdeg
		double ans = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg))));
		System.out.println(ans);

		scan.close();

	}

} 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 deg = 0;
		deg = (30 * h) + (0.5 * m) - (6 * m);

		// a2 = b2 + c2 - 2bcCOSdeg
		double ans = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(deg))));
		System.out.println(ans);

		scan.close();

	}

}
