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()).sorted.toArray
  
  class DP(n:Int, m:Int, coins:Array[Int]) {
    val inf = Int.MaxValue >> 1
    val memo = Array.fill(M)(Array.fill(n+1)(inf))
    for (row <- memo) row(0) = 0
    for (i <- 0 until n+1) memo(0)(i) = i

    def solver():Int = {
      for (i <- 1 until m; j <- 1 until n+1) {
        val c0 = memo(i-1)(j)
        val c1 = if (j < coins(i)) inf else memo(i)(j-coins(i))+1
        memo(i)(j) = if (c0 < c1) c0 else c1
      }
      memo(m-1)(n)
    }
  }

  val dp = new DP(N, M, coins)
  println(dp.solver())

}
