require 'prime'

class Array
  def make_power
    (0..self[1]).map { |x| self[0] ** x }
  end
end

n, m = gets.split.map(&:to_i)
ps = Prime.prime_division(m)
if ps.empty?
  p 1
  exit
elsif ps.size == 1
  ds = ps.map(&:make_power)[0].reverse
else
  ds = ps.map(&:make_power).inject(&:product).map(&:flatten).map { |x| x.inject(:*) }.sort.reverse
end
p ds.bsearch { |x| x <= m / n }