require 'prime'

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

factors = Prime.prime_division(m)
i_counts = '1' * (factors.map { |a, b| b }.inject(:+))
length = i_counts.size
nums = factors.map { |a, b| Array.new(b) { a } }.flatten

result = 1
i_counts.to_i(2).downto(1).each do |i|
  flags = i.to_s(2).rjust(length, '0').chars

  factor = 1
  rest = 1
  flags.each.with_index(0) do |x, idx|
    if x == '1'
      factor *= nums[idx]
    else
      rest *= nums[idx]
    end
  end

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