main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  print $ solve n m

solve :: Int -> Int -> Int
solve n m | m `mod` n == 0 = m `div` n
          | otherwise = maximum $ filter (<= m `div` n) $ factors m

factors :: Int -> [Int]
factors m = [x | x <- [2..m], m `mod` x == 0]
