require "prime"
n, m = gets.chomp.split.map(&:to_i)

if m == 1
  puts 1
  exit
end

factors = Prime.prime_division(m)

#全素因数を求める
factors = factors.map do |factor|
  (factor[1] + 1).times.map do |i|
  factor[0] ** i
  end
end
until (factors.size == 1) do
  factors = factors.each_slice(2).map{ |a, b|
    if b
      a.product(b).map{|c| c.reduce(&:*)}
    else
      a
    end
  }
end

factors = factors[0].sort.reverse
puts factors.find{|fac| fac <= (m/n)}