import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int h = getInt(sc);
		int m = getInt(sc);

		double angleA = (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m);

		double angleB = (double) (360.0 / 60.0) * (double) m;
		double angle = Math.abs(angleA - angleB);
		if (angle == 0) {
			System.out.println(Math.abs(b - a));
		} else if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int h = getInt(sc);
		int m = getInt(sc);

		double angleA = (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m);

		double angleB = (double) (360.0 / 60.0) * (double) m;
		double angle = Math.abs(angleA - angleB);
		if (angle == 0) {
			System.out.println(Math.abs(b - a));
		} else if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int h = getInt(sc);
		int m = getInt(sc);

		double angleA = (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m);

		double angleB = (double) (360.0 / 60.0) * (double) m;
		double angle = Math.abs(angleA - angleB);
		if (angle == 0) {
			System.out.println(Math.abs(b - a));
		} else if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		}

	} main {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int h = getInt(sc);
		int m = getInt(sc);

		double angleA = (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m);

		double angleB = (double) (360.0 / 60.0) * (double) m;
		double angle = Math.abs(angleA - angleB);
		if (angle == 0) {
			System.out.println(Math.abs(b - a));
		} else if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = getInt(sc); a getInt(sc) getInt sc int b = getInt(sc); b getInt(sc) getInt sc int h = getInt(sc); h getInt(sc) getInt sc int m = getInt(sc); m getInt(sc) getInt sc double angleA = (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m); angleA (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m) (double) (360.0 / 720.0) 360.0 720.0 ((double) h * 60.0 + (double) m) (double) h * 60.0 (double) h 60.0 (double) m double angleB = (double) (360.0 / 60.0) * (double) m; angleB (double) (360.0 / 60.0) * (double) m (double) (360.0 / 60.0) 360.0 60.0 (double) m double angle = Math.abs(angleA - angleB); angle Math.abs(angleA - angleB) Math.abs Math angleA - angleB angleA angleB if (angle == 0) {
			System.out.println(Math.abs(b - a));
		} else if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		} angle == 0 angle 0 {
			System.out.println(Math.abs(b - a));
		} System.out.println(Math.abs(b - a)) System.out.println System.out System System.out Math.abs(b - a) Math.abs Math b - a b a if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		} angle == 180 angle 180 {
			System.out.println((double) (a + b));
		} System.out.println((double) (a + b)) System.out.println System.out System System.out (double) (a + b) a b {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		} double cos = Math.cos(Math.toRadians(angle)); cos Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos)) System.out.println System.out System System.out Math.sqrt(a * a + b * b - 2.0 * a * b * cos) Math.sqrt Math a * a + b * b - 2.0 * a * b * cos a * a + b * b a * a a a b * b b b 2.0 * a * b * cos b 2.0 * a * b * cos 2.0 a b cos String[] args args /**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	} getLong {

		return Long.parseLong(sc.next());
	} return Long.parseLong(sc.next()); Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc Scanner sc sc /**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	} getInt {

		return Integer.parseInt(sc.next());
	} return Integer.parseInt(sc.next()); Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Scanner sc sc /**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	} getString {

		return sc.next();
	} return sc.next(); sc.next() sc.next sc Scanner sc sc /**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	} getIntArray {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	} String line = ""; line "" while (line.equals("")) {
			line = sc.nextLine();
		} line.equals("") line.equals line "" {
			line = sc.nextLine();
		} line = sc.nextLine() line sc.nextLine() sc.nextLine sc String[] strArray = line.split(" "); strArray line.split(" ") line.split line " " int[] intArray = new int[strArray.length]; intArray new int[strArray.length] strArray.length strArray strArray.length for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		} int i = 0; int i = 0; i 0 i < strArray.length i strArray.length strArray strArray.length i++ i++ i {
			intArray[i] = Integer.parseInt(strArray[i]);
		} {
			intArray[i] = Integer.parseInt(strArray[i]);
		} intArray[i] = Integer.parseInt(strArray[i]) intArray[i] intArray i Integer.parseInt(strArray[i]) Integer.parseInt Integer strArray[i] strArray i return intArray; intArray Scanner sc sc public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int h = getInt(sc);
		int m = getInt(sc);

		double angleA = (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m);

		double angleB = (double) (360.0 / 60.0) * (double) m;
		double angle = Math.abs(angleA - angleB);
		if (angle == 0) {
			System.out.println(Math.abs(b - a));
		} else if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int h = getInt(sc);
		int m = getInt(sc);

		double angleA = (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m);

		double angleB = (double) (360.0 / 60.0) * (double) m;
		double angle = Math.abs(angleA - angleB);
		if (angle == 0) {
			System.out.println(Math.abs(b - a));
		} else if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		int b = getInt(sc);
		int h = getInt(sc);
		int m = getInt(sc);

		double angleA = (double) (360.0 / 720.0) * ((double) h * 60.0 + (double) m);

		double angleB = (double) (360.0 / 60.0) * (double) m;
		double angle = Math.abs(angleA - angleB);
		if (angle == 0) {
			System.out.println(Math.abs(b - a));
		} else if (angle == 180) {
			System.out.println((double) (a + b));
		} else {
			double cos = Math.cos(Math.toRadians(angle));
			System.out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * cos));
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}
