from math import cos, radians, sqrt
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if 180 <= int(r):
  r1 = 360 - int(r)
else:
  r1 = r
cos = cos(radians(r1))
d = int(a1) + int(b1) - 2 * int(ab) * float(cos)
ans = d ** (1/2)
print(ans)