split :: (Eq a) => a -> [a] -> [a] -> [[a]]
split a [] current = [(reverse current)]
split a (x:xs) current =
    if a == x then
        (reverse current) : (split a xs [])
    else
        split a xs (x:current)
        
split2 a b = split a b []

solve :: [Double] -> IO ()
solve l = do
    putStrLn $ show $ ans
    where
        a = head l
        b = l !! 1
        h = l !! 2
        m = l !! 3
        hh = h + (m / 60)
        ah = a * (cos (2 * pi * hh / 12))
        bh = b * (cos (2 * pi * m / 60))
        height = ah - bh
        aw = a * (sin (2 * pi * hh / 12))
        bw = b * (sin (2 * pi * m / 60))
        width = aw - bw
        ans = sqrt $ (height * height) + (width * width)

main = do
    l <- (map (read)) <$> ((split2 ' ') <$> getLine)
    solve l