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

num = []

for i in 1..Math.sqrt(M).to_i
	if M%i == 0
		num.push(i)
		num.push(M/i)
	end
end

num = num.uniq.sort


previ = 0
for i in num
	if i > M/N
		puts "#{previ}"
		break
	end
	previ = i
end