from math import sin, radians, cos, sqrt
lst = [int(i) for i in input().split()]
A, B, H, M = tuple(lst)
angle = M * 6 - (H * 30 + M * 0.5)
if abs(angle) > 180:
  angle = 360 - abs(angle)
elif abs(angle) == 180:
  X = A + B
  print(X)
elif abs(angle) == 0:
  print(0)
else:
  angle = abs(angle)
  area = A * B * sin(radians(angle)) / 2
  co = sqrt(1 - sin(radians(angle)) ** 2)
  X = sqrt(A**2 + B**2 - 2*A*B*co)
  print(X)