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