N,M = gets.strip.split.map(&:to_i)

require 'prime'

class Integer
  def my_divisor_list
    divisors = [1]
    primes = []
    Prime.prime_division(self).each do |prime|
      prime[1].times {primes << prime[0]}
    end

    1.upto(primes.size) do |i|
      primes.combination(i) do |prime|
        divisors << prime.inject{|a,b| a *= b}
      end
    end

    divisors.uniq!
    divisors.sort!
    return divisors
  rescue ZeroDivisionError
    return
  end
end

i = 0
x = M.my_divisor_list
cnt = M
while x[i] < M
  if x[i] > (M/N)
    cnt = x[i - 1]
    break
  end
  i += 1
end

puts cnt