{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Data.STRef 
import Data.List
import Data.Char
import qualified Data.Map.Strict as M

main :: IO ()
main = do
    [a,b,h,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let theta = (pi /6.0)*((fromIntegral h)-(11/60)*(fromIntegral m))
    print $ sqrt $ (fromIntegral a)^2 + (fromIntegral b)^2 - 2*(fromIntegral a)*(fromIntegral b)*(cos theta)