solve :: [Float] -> Float
solve (s:l:h:m:_) = sqrt $ (ax - bx)^2 + (ay - by)^2
    where d1 = (60*h + m) * pi / 360
          ax = s*cos(d1)
          ay = s*sin(d1)
          d2 = (6*m) * pi / 180
          bx = l*cos(d2)
          by = l*sin(d2)


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