require 'prime'
N, M = gets.split.map(&:to_i)

primes = Prime.prime_division(M)

num = 1
primes.each do |pr, n|
    num *= n+1
end
divs = []
num.times do |i|
    prod = 1
    primes.each do |pr, n|
        prod *= pr ** (i % (n+1))
        i /= n+1
    end
    divs.push(prod)
end

puts divs.select{|d| d*N <= M}.max