main = interact $ unlines . map (show . koto_subway) . read' . lines
 where
  read' ("0 0":_) = []
  read' (de:xs) = map read (words de) : read' xs

koto_subway [d,e] = minimum [abs (distance x y - fromIntegral e) | x<-[0..d], y<-[0..d], x+y==d]
 where distance x y = sqrt (fromIntegral (x^2 + y^2))