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