main = do
    [a, b, h, m] <- map read . words <$> getLine :: IO [Double]
    let theta_h = (h + m / 60) / 12 * 2 * pi
    let theta_m = m / 60 * 2 * pi
    let x_h = a * cos theta_h
    let y_h = a * sin theta_h
    let x_m = b * cos theta_m
    let y_m = b * sin theta_m
    let d = sqrt ((x_h - x_m) ^ 2 + (y_h - y_m) ^ 2)
    print d
