import scala.io.StdIn
import scala.collection.mutable.{ Map => MMap }

object Main {
  def main(args: Array[String]) = {
    val Seq(n, m, _*) = StdIn.readLine.split(" ").map(_.toInt).toSeq
    val coins = StdIn.readLine.split(" ").map(_.toInt)
    val dp = MMap[Int, Int]()
    val result = coin(n, dp, coins)
    println(result)
  }

  def coin(n: Int, dp: MMap[Int, Int], coins: Seq[Int]): Int = {
    if (coins contains n) {
      dp(n) = 1
      return 1
    }
    if (dp contains n) {
      return dp(n)
    }
    val res = coins.map(n - _).filter(_ > 0).map(coin(_, dp, coins)).min + 1
    dp(n) = res
    res
  }
}

