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

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