import Control.Applicative
import Text.Printf

main :: IO ()
main = solve <$> f >>= printf "%.10f\n"
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Double
solve [a, b, h, m] = sqrt $ fromIntegral a * fromIntegral a +
                     fromIntegral b * fromIntegral b
                     - 2.0 * fromIntegral a * fromIntegral b * cos (tm - th)
  where
    tm = pi * fromIntegral m / 30.0
    th = pi * (fromIntegral h / 6.0 + fromIntegral m / 360.0)
