import algorithm,sequtils,strutils var l,n = parseInt readLine stdin var w = stdin.readLine.split.map parseInt w.sort cmp var cnt = 0 for x in w: if l-x > 0: l -= x inc cnt echo cnt