import Data.List

toInt :: String -> Int
toInt = read :: String -> Int

main = do
  [a, b, h, m] <- map fromIntegral . map toInt . words <$> getLine
  let alpha = 2*pi*(h/12 + m/720)
  let beta = 2*pi*(m/60)
  print $ sqrt ((a*(cos alpha)-b*(cos beta))^2 + (a*(sin alpha)-b*(sin beta))^2)
