require 'prime'

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

factors = Prime.prime_division(m)
counts = ('1' * factors.map { |a, b| b }.inject(:+)).to_i(2)
nums = factors.reverse.map do |a, b|
  Array.new(b) { a }
end.flatten

result = 1
counts.downto(1).each do |i|
  flags = i.to_s(2).chars.map(&:to_i)
  factor = nums.select.with_index(0) { |_, idx| flags[idx] == 1 }.inject(:*)
  rest = nums.select.with_index(0) { |_, idx| flags[idx] == 0 }.inject(:*) || 1

  if rest >= n && factor >= result
    result = factor
  end
end
puts result
