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 $ takeWhile (<=m`div`n) [x | x <- [1..m], m `mod` x == 0]
