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));
	}
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz