n,m = gets.chomp.split(" ").map{|item| item.to_i}
c = gets.chomp.split(" ").map{|item| item.to_i}
t = Array.new(n,50000)
t.unshift(0)
for i in 0..(m-1) do
	for j in c[i]..n do
		t[j] = (t[j] <= t[j-c[i]]+1) ? t[j] : t[j-c[i]]+1
	end
end
print("#{t[n]}\n")