import math
A, B, H, M = map(int, input().split())
l = (360/60)*M
s = (360/12)*H + (360/12/60)*M
theta = max(l, s) - min(l, s)
theta = min(theta, 360-theta)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta))))