fun main(){ var l = readLine()!!.toInt() val n = readLine()!!.toInt() val w = readLine()!!.split(" ").map(String::toInt).sortedBy{it} var cnt = 0 for (i in w){ if(l - i < 0) break cnt++ l -= i } println(cnt) }