import math

A = int(input())
B = int(input())
H = int(input())
M = int(input())
c = 0

h = H * 30 + 0.5 * M
m = 6 * M
#hh = abs(h - m)
hh = h - m
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = A * A + B * B - 2 * A * B * math.cos(c)
print(math.sqrt(C))