
n,m=gets.split.map(&:to_i)
d=gets.split.map(&:to_i)
d.sort!

dp=Array.new(50001,10000000)
dp[0]=0
for i in 0..n
    for j in 0..m-1
        if(i+d[j]>n)
            break
        end
       dp[i+d[j]]=[dp[i+d[j]],dp[i]+1].min
    
    end
end

p dp[n]
