require 'prime'

n, m = gets.chomp.split(' ').map(&:to_i)

factors = Prime.prime_division(m)
nums = factors.map { |a, b| Array.new(b) { a } }.flatten
count = factors.map {|_, b| b}.inject(:+)

fs = []
count.downto(1).each do |i|
  list = nums.combination(i).to_a.uniq
  list.each do |ns|
    fs << ns.inject(:*) || 1
  end
end
fs.uniq.sort_by {|x| -1 * x}.each do |factor|
  rest = m / factor
  if rest >= n
    puts factor
    exit
  end
end
