import java.io.PrintWriter
import java.util.Scanner
import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)
  
  def solve(): Int = {
    val L, N = sc.nextInt()
    val W = List.fill(N)(sc.nextInt()).sorted

    @tailrec
    def loop(acc: Int, xs: List[Int]): Int =
      xs match {
        case Nil =>
          N
        case h :: t if h > acc =>
          N - xs.length
        case h :: t =>
          loop(acc - h, t)
      }

    loop(L, W)
  }
  
  out.println(solve)
  out.flush
}