require "prime"

N, M = STDIN.gets.chomp.split(" ").map(&:to_i)

primes = Prime.prime_division(M).map{|prime| Array.new(prime[1], prime[0])}.flatten
divs = [1, M] + (1..(primes.size - 1)).map{|num| primes.combination(num).map{|prime| prime.inject{|acc, p| acc *= p}}}.flatten

answer = divs.uniq.select{|div| div <= M / N}.sort.reverse.max
puts answer
