
n,m = STDIN.gets.chomp.split(/ +/).map(&:to_i)

ret = 0

if m % n == 0
  ret = m / n
else

	divider = []
	
	mm = m
	
	i = 2
	maxDiv = 0
  while mm >= Math.sqrt(m) do
	    if mm % i == 0
	      if i >= n
	      	maxDiv = i
	      	break
	      end
	      mm /= i
	    end
	    i += 1
	end
  
  if maxDiv == 0 
    maxDiv = m
  end
  
	ret = m / maxDiv

end

puts ret
