def min(a,b)
  if a<b
    return a
  else
    return b
  end
end

n,m=gets.chomp.split(/ /).map{|i| i.to_i}
c=Array.new(m)
c=gets.chomp.split(/ /).map{|i| i.to_i}
d=Array.new(m).map{Array.new(n+1,10000)}
for i in 0..m-1
  d[i][0]=0
end
for j in 0..n
  if j%c[0]==0
    d[0][j]=j/c[0]
  end
end
for i in 1..m-1
  for j in 1..n
    if j>=c[i]
      d[i][j]=min(d[i-1][j],d[i][j-c[i]]+1)
    else
      d[i][j]=d[i-1][j]
    end
  end
end
puts d[m-1][n]