


a = int(input())
b = int(input())
h = int(input())
m = int(input())
ans = 0

m_r = m/5

h_r = h + m/60

reg = (h_r - m_r)/12*360
ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(reg)))

print(ans)