module Main where

dist :: Double -> Double -> Double -> Double -> Double
dist a1 a2 b1 b2 = sqrt $ ((a1 - b1) ^ 2) + ((a2 - b2) ^ 2)

hToDeg = (* 30)
mToDeg = (* 6)
degToRad = (* (pi / 180))

toCarteesian :: Double -> Double -> (Double, Double)
toCarteesian v r = (r * cos v , r * sin v)

-- a is legth of hour
-- b length of minute
-- h:m is the time
main :: IO ()
main = do
	input <- getLine
	let (a:b:h:m:_) = map read $ words input
	let (a1, a2) = toCarteesian (degToRad . (+ m * (30 / 60)) . hToDeg $ h) a
	let (b1, b2) = toCarteesian (degToRad . mToDeg $ m) b
	putStrLn . show $ dist a1 a2 b1 b2

