
enumDivisor x b = x : f (min b (x`div`2)) where
  f 1 = [1]
  f n
    | x`mod`n==0 = n : f (n-1)
    | otherwise = f (n-1)

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  print.head $ enumDivisor m (m`div`n)
