main = do
    [a, b, h, m] <- (map read . words) <$> getLine
    putStrLn $ show $ clockDistance a b h m

clockDistance :: Double -> Double -> Double -> Double -> Double
clockDistance hlen mlen h m =
    sqrt $ (hlen ** 2) + (mlen ** 2) - 2.0 * hlen * mlen * (cos angle)
    where
        ha = 2.0 * pi * (h / 12.0 + m / 720.0) 
        ma = 2.0 * pi * (m / 60.0)
        angle1 = abs $ ha - ma
        angle = min angle1 (pi * 2.0 - angle1)