import math

a, b, h, m = list(map(int, input().split()))

if m == 0:
	m = 60
if h == 0
	h = 12

if h/12 > m/60:
	k = (h/12 - m/60) * 360
elif h/12 < m/60:
	k = (m/60 - h/12) * 360
else:
	print(0)
	exit()
print(math.sqrt((a**2) + (b**2) - (2 * a * b * math.cos(math.radians(k)))))
