main = do
  [hs,ms,h,m] <- map read . words <$> getLine :: IO [Double]
  putStrLn $ show $ nagasa hs ms h m
-- a2 + b2 - 2ab csin c
-- 度 × 円周率 ÷ 180

mpos m = (360 / 60) * m
hpos h m = ((360 / 12) * h) + (30 / 60) * m
kakudo h m = abs ( (mpos m) - (hpos h m) )
mCos h m = (kakudo h m) * pi / 180

nagasa hs ms h m = sqrt $ (hs ** 2) + (ms ** 2) - ( 2 * hs * ms * (cos (mCos h m)) )