import qualified Data.ByteString.Char8 as B
import           Data.Maybe (fromJust)

main :: IO ()
main = do
  [a, b, h, m] <- getInts
  let alpha = (fromIntegral h + beta) / 12
      beta = fromIntegral m / 60
      theta = 2 * pi * (alpha - beta)
      ans = lawOfCos (fromIntegral a) (fromIntegral b) theta
  print ans

getInts :: IO [Int]
getInts = fmap (fst . fromJust . B.readInt) . B.words <$> B.getLine

lawOfCos :: Double -> Double -> Double -> Double
lawOfCos b c alpha = sqrt a2
  where
    a2 = b ^ (2 :: Int) + c ^ (2 :: Int) - 2 * b * c * cos alpha
