import math

A,B,H,M= map(int, input().split())

if H == 0:
  H = 12
if M == 0:
  M = 60


kakudo = ((12-H)*30) + (60-M)
Area = ((A**2) + (B**2))-((2*A*B)*math.cos(math.radians(kakudo)))

print(math.sqrt(Area))
