main = do  
    [a, b, h, m] <- map read . words <$> getLine :: IO [Double]
    let theta = (30 * h - 5.5 * m) * pi / 180  
    let a_times = a ^ 2
    let b_times = b ^ 2
    let total_cos = cos theta

    print $ sqrt ( a_times + b_times - 2 * a * b * total_cos )
