import java.util.Scanner

object Main extends App { 
  val sc = new Scanner(System.in)
  val N, M = sc.nextInt()
  val coins = (for (i <- 1 to M) yield sc.nextInt).toList
  val inf = Int.MaxValue >> 1

  class DP(n:Int, coins:List[Int]) {
    val memo:Array[Int] = Array.fill(n+1)(inf)
    memo.update(0, 0)

    def solver():Int = {
      for (c <- coins; i <- 1 to n) {
        if (i < c) memo(i)
        else memo.update(i, (memo(i) min (memo(i-c)+1)))
      }
      memo(n)
    }
  }
  
  val dp = new DP(N, coins)

  println(dp.solver())

}
