require "prime"

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

primes = Prime.prime_division(M).select{|prime| prime[0] <= M / N}.map{|prime| Array.new(prime[1], prime[0])}.flatten

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

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