def main
  n, m = gets.split(" ").map(&:to_i)
  arr = Array.new(n + 1, 0)
  coins = gets.split(" ").map(&:to_i)
  buf = [0]
  count = 0
  while arr.last == 0
    temp = []
    buf.each{|i|
      coins.each{|j|
        if i + j <= n and arr[i + j] == 0
          arr[i + j] = count + 1
          temp << i + j
        end
      }
    }
    buf = temp
    count += 1
  end
  puts arr.last
end
main