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' :: IO [Double]

    let a' = a :+ 0
        b' = b :+ 0

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

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


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