solve :: [Double] -> Double
solve [a,b,h,m] = sqrt((a * a) + (b * b) - (2 * a * b * cos(angle * pi / 180.0)))
 where angle = abs $ (h * 30) + (0.5 * m) - (m * 6)
main = print =<< solve . map read . words <$> getLine