import math
a, b, h, m = map(int, input().split())
ax = a * math.cos(math.radians((h/12 + 1/12 * m/60) * 360))
ay = a * math.sin(math.radians((h/12 + 1/12 * m/60) * 360))
bx = b * math.cos(math.radians(m/60 * 360))
by = b * math.sin(math.radians(m/60 * 360))
print(math.sqrt((ax-bx)**2 + (ay-by)**2))