object Main { def main(args: Array[String]): Unit = { val l : Int = readLine().toInt val n : Int = readLine().toInt var now : Int = 0 var count : Int = 0 for(w <- (readLine().split(' ').map(_.toInt).sorted :+ l+1)){ now += w if(now > l){ println(count) return } count += 1 } } }