def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
 
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end


n,m = gsmi

k = 0
(1..(Math.sqrt(m).to_i)).each do |i|
	if m%i==0 && (i>=n || m/i>=n)
		if i>=n && m/i>=n
			k = max(k,m/i)
		else
			k = max(k,i)
		end
	end
end

puts k