import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [a, b, h, m] <- map unsafeTextToDouble . T.words <$> T.getLine :: IO [Double]
  let
    c = sqrt $ a * a + b * b - 2 * a * b * cos ((h / 6 - 11 * m / 360) * pi) :: Double
  print c

unsafeTextToDouble :: T.Text -> Double
unsafeTextToDouble s = case T.double s of
  Right (x, _) -> x
{-# INLINE unsafeTextToDouble #-}
