import Data.List
import Data.Ord

main = do
    [n,m] <- map read . words <$> getLine
    let ans = head . dropWhile (\d -> m `div` d < n). sortOn Down $ divisor m
    print ans

divisor n = foldr f [] $ takeWhile ((<= n) . (^ 2)) [1 .. n]
  where
    f x ds
      | r == 0
      , q /= x = x : q : ds
      | r == 0 = x : ds
      | otherwise = ds
      where
        (q, r) = n `divMod` x