solve :: [Float] -> Float
solve (s:l:h:m:_) = sqrt $ s^2 + l^2 - 2*s*l*cos(theta)
    where sdeg  = 0.5*(60*h + m)
          ldeg  = 6.0*m
          deg   = abs $ sdeg - ldeg
          theta = deg * pi / 180

main :: IO ()
main = getLine >>= print . solve . map read . words