import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a,b,h,m] <- map fromIntegral <$> getIntList
    let ji = (h*60 + m) / 2
        hun = 6 * m
        kaku = if 180 < abs (ji - hun) then abs (ji-hun)-180 else abs (ji-hun)
        c | kaku == 0 || kaku == 180 = abs (a-b)
          | otherwise = sqrt $ a^2 + b^2 - 2*a*b* (cos (pi * kaku / 180)) 
    print c