import math
A,B,H,M = map(int,input().split())

a = H * 30 + M * 0.5
b = M * 6
c = abs(a-b)
c = c - 180 if c > 180 else c
c = math.radians(c)
d = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(c))
print(d)