import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		// 1周のうちH時間でどれくらい進んだか 
		double h = (double)H / 12.0;
		h += (double)M / 60.0 / 12.0; // 分針
		// 1周のうちM分でどれくらい進んだか
		double m = (double)M / 60.0;
		// 角度
		double rad = Math.PI * 2 * (h - m);
		// System.out.println(rad);
		// 辺の長さ
		double rsq = (A * A) + (B * B) - (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(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		// 1周のうちH時間でどれくらい進んだか 
		double h = (double)H / 12.0;
		h += (double)M / 60.0 / 12.0; // 分針
		// 1周のうちM分でどれくらい進んだか
		double m = (double)M / 60.0;
		// 角度
		double rad = Math.PI * 2 * (h - m);
		// System.out.println(rad);
		// 辺の長さ
		double rsq = (A * A) + (B * B) - (2 * A * B * Math.cos(rad));
		System.out.println(Math.sqrt(rsq));
	}
} Main public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		// 1周のうちH時間でどれくらい進んだか 
		double h = (double)H / 12.0;
		h += (double)M / 60.0 / 12.0; // 分針
		// 1周のうちM分でどれくらい進んだか
		double m = (double)M / 60.0;
		// 角度
		double rad = Math.PI * 2 * (h - m);
		// System.out.println(rad);
		// 辺の長さ
		double rsq = (A * A) + (B * B) - (2 * A * B * Math.cos(rad));
		System.out.println(Math.sqrt(rsq));
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		// 1周のうちH時間でどれくらい進んだか 
		double h = (double)H / 12.0;
		h += (double)M / 60.0 / 12.0; // 分針
		// 1周のうちM分でどれくらい進んだか
		double m = (double)M / 60.0;
		// 角度
		double rad = Math.PI * 2 * (h - m);
		// System.out.println(rad);
		// 辺の長さ
		double rsq = (A * A) + (B * B) - (2 * A * B * Math.cos(rad));
		System.out.println(Math.sqrt(rsq));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc sc.close() sc.close sc double h = (double)H / 12.0; h (double)H / 12.0 (double)H 12.0 h += (double)M / 60.0 / 12.0 h (double)M / 60.0 / 12.0 (double)M / 60.0 / 12.0 (double)M 60.0 12.0 double m = (double)M / 60.0; m (double)M / 60.0 (double)M 60.0 double rad = Math.PI * 2 * (h - m); rad Math.PI * 2 * (h - m) Math.PI * 2 * (h - m) Math.PI Math Math.PI 2 (h - m) h m double rsq = (A * A) + (B * B) - (2 * A * B * Math.cos(rad)); rsq (A * A) + (B * B) - (2 * A * B * Math.cos(rad)) (A * A) + (B * B) (A * A) A A (B * B) B B (2 * A * B * Math.cos(rad)) B 2 * A * B * Math.cos(rad) 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 final String[] args args public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		// 1周のうちH時間でどれくらい進んだか 
		double h = (double)H / 12.0;
		h += (double)M / 60.0 / 12.0; // 分針
		// 1周のうちM分でどれくらい進んだか
		double m = (double)M / 60.0;
		// 角度
		double rad = Math.PI * 2 * (h - m);
		// System.out.println(rad);
		// 辺の長さ
		double rsq = (A * A) + (B * B) - (2 * A * B * Math.cos(rad));
		System.out.println(Math.sqrt(rsq));
	}
} public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		// 1周のうちH時間でどれくらい進んだか 
		double h = (double)H / 12.0;
		h += (double)M / 60.0 / 12.0; // 分針
		// 1周のうちM分でどれくらい進んだか
		double m = (double)M / 60.0;
		// 角度
		double rad = Math.PI * 2 * (h - m);
		// System.out.println(rad);
		// 辺の長さ
		double rsq = (A * A) + (B * B) - (2 * A * B * Math.cos(rad));
		System.out.println(Math.sqrt(rsq));
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		sc.close();
		// 1周のうちH時間でどれくらい進んだか 
		double h = (double)H / 12.0;
		h += (double)M / 60.0 / 12.0; // 分針
		// 1周のうちM分でどれくらい進んだか
		double m = (double)M / 60.0;
		// 角度
		double rad = Math.PI * 2 * (h - m);
		// System.out.println(rad);
		// 辺の長さ
		double rsq = (A * A) + (B * B) - (2 * A * B * Math.cos(rad));
		System.out.println(Math.sqrt(rsq));
	}
}
