import util.control.Breaks._

object Main extends App {
  val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)
  val coins = io.StdIn.readLine().split(' ').map(_.toInt)
  val counts = Array.fill(n+1)(Int.MaxValue)
  val queue = collection.mutable.Queue.empty[Int]
  coins.withFilter(_<=n).foreach {n =>
    counts(n) = 1
    queue.enqueue(n)
  }
  breakable(
    while (queue.nonEmpty) {
      val current = queue.dequeue()
      if (current == n) break()
      coins.foreach{c =>
        val next = c+current
        if (next <= n && counts(current)+1 < counts(next)) {
          counts(next) = counts(current) + 1
          queue.enqueue(next)
        }
      }
    }
  )
  println(counts(n))
}
