main :: IO()
main = do
    [a, b, h, m] <- map read . words <$> getLine
    let angle = abs ( (30.0 * h + 0.5 * m) - ( 6.0 *  m) ) * (pi / 180.0)

    print $ sqrt(a ^ 2 + b ^ 2 - 2 * a * b * (cos angle))
