

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hLong = sc.nextInt();
		int mLong = sc.nextInt();
		int hour = sc.nextInt();
		int minute = sc.nextInt();
		int mAngle = 6 * minute;
		double hAngle = 30 * hour +   0.5 * minute;
		double angleDiff = Math.abs(hAngle - mAngle);
		double result = 0;

			double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff));
			result = Math.sqrt(aSq);

		System.out.println(result);

	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hLong = sc.nextInt();
		int mLong = sc.nextInt();
		int hour = sc.nextInt();
		int minute = sc.nextInt();
		int mAngle = 6 * minute;
		double hAngle = 30 * hour +   0.5 * minute;
		double angleDiff = Math.abs(hAngle - mAngle);
		double result = 0;

			double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff));
			result = Math.sqrt(aSq);

		System.out.println(result);

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hLong = sc.nextInt();
		int mLong = sc.nextInt();
		int hour = sc.nextInt();
		int minute = sc.nextInt();
		int mAngle = 6 * minute;
		double hAngle = 30 * hour +   0.5 * minute;
		double angleDiff = Math.abs(hAngle - mAngle);
		double result = 0;

			double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff));
			result = Math.sqrt(aSq);

		System.out.println(result);

	} main {
		Scanner sc = new Scanner(System.in);
		int hLong = sc.nextInt();
		int mLong = sc.nextInt();
		int hour = sc.nextInt();
		int minute = sc.nextInt();
		int mAngle = 6 * minute;
		double hAngle = 30 * hour +   0.5 * minute;
		double angleDiff = Math.abs(hAngle - mAngle);
		double result = 0;

			double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff));
			result = Math.sqrt(aSq);

		System.out.println(result);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int hLong = sc.nextInt(); hLong sc.nextInt() sc.nextInt sc int mLong = sc.nextInt(); mLong sc.nextInt() sc.nextInt sc int hour = sc.nextInt(); hour sc.nextInt() sc.nextInt sc int minute = sc.nextInt(); minute sc.nextInt() sc.nextInt sc int mAngle = 6 * minute; mAngle 6 * minute 6 minute double hAngle = 30 * hour +   0.5 * minute; hAngle 30 * hour +   0.5 * minute 30 * hour 30 hour 0.5 * minute 0.5 minute double angleDiff = Math.abs(hAngle - mAngle); angleDiff Math.abs(hAngle - mAngle) Math.abs Math hAngle - mAngle hAngle mAngle double result = 0; result 0 double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff)); aSq Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff)) Math.pow(hLong, 2) + Math.pow(mLong, 2) Math.pow(hLong, 2) Math.pow Math hLong 2 Math.pow(mLong, 2) Math.pow Math mLong 2 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff)) mLong 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff)) 2 hLong mLong Math.cos(Math.toRadians(angleDiff)) Math.cos Math Math.toRadians(angleDiff) Math.toRadians Math angleDiff result = Math.sqrt(aSq) result Math.sqrt(aSq) Math.sqrt Math aSq System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hLong = sc.nextInt();
		int mLong = sc.nextInt();
		int hour = sc.nextInt();
		int minute = sc.nextInt();
		int mAngle = 6 * minute;
		double hAngle = 30 * hour +   0.5 * minute;
		double angleDiff = Math.abs(hAngle - mAngle);
		double result = 0;

			double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff));
			result = Math.sqrt(aSq);

		System.out.println(result);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hLong = sc.nextInt();
		int mLong = sc.nextInt();
		int hour = sc.nextInt();
		int minute = sc.nextInt();
		int mAngle = 6 * minute;
		double hAngle = 30 * hour +   0.5 * minute;
		double angleDiff = Math.abs(hAngle - mAngle);
		double result = 0;

			double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff));
			result = Math.sqrt(aSq);

		System.out.println(result);

	}

} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hLong = sc.nextInt();
		int mLong = sc.nextInt();
		int hour = sc.nextInt();
		int minute = sc.nextInt();
		int mAngle = 6 * minute;
		double hAngle = 30 * hour +   0.5 * minute;
		double angleDiff = Math.abs(hAngle - mAngle);
		double result = 0;

			double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff));
			result = Math.sqrt(aSq);

		System.out.println(result);

	}

}
