import Data.List

divisorsLeq :: Int -> Int -> [Int]
divisorsLeq m n
  | m == 0    = [n, n-1 .. 0]
  | sqrtM > n = divsIn [n, n-1 .. 1]
  | otherwise = reverse (takeWhile (<= n) $ map snd divPairs)
                ++ (if sqrtM * sqrtM == m' then [sqrtM] else [])
                ++ map fst divPairs
  where
    m' = abs m
    sqrtM = ceiling (sqrt $ fromIntegral m' :: Double)
    divsIn xs = [x | x <- xs, m' `mod` x == 0]
    divPairsIn xs = [(x,y) | x <- xs, let (y,r) = m' `divMod` x, r == 0]
    divPairs = divPairsIn [sqrtM, sqrtM-1 .. 1]

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  let mdn = m `div` n
  putStrLn $ show $ head $ divisorsLeq m mdn