n = gets.split[0].to_i
c = gets.split.map(&:to_i).select {|i| i <= n}
m = (0..n+1).to_a
c.each {|e| m[e]=1 }

(2..n).each do |i|
  c.each {|j| m[i] = m[i-j]+1 if j <= i && m[i-j]+1 < m[i] } if m[i] >= 2
end

puts m[n]