line = gets
num = line.split(" ")
n,m = num[0].to_i , num[1].to_i
line = gets
coin = []
coin = line.split(" ")
dp = Array.new(50001,100000000)
dp[0] = 0
n.times{|i|
	m.times{|j|
		nx = coin[j].to_i + i.to_i
		dp[nx] = dp[nx] > dp[i] + 1 ? dp[i] + 1 : dp[nx] if nx <= n
	}
}
p dp[n]