import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Complex

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [a,b,h,m] <- map fromIntegral <$> r'

    let h' = (60 * h + m) / 60 / 12
        m' = m / 60

    print $ magnitude ((a :+ 0) -  rotate (m' - h') (b :+ 0))

rotate :: Double -> Complex Double -> Complex Double
rotate ofFullCirc = (* (0 :+ 1) ** (4 * ofFullCirc :+ 0))