import algorithm, strutils, sequtils let l = stdin.readLine().parseInt() discard stdin.readLine() let sortedW = stdin.readLine().split(' ').map(parseInt).sorted(proc (x, y: int): int = x - y) var sum: int = 0 for idx, w in sortedW: sum += w if sum >= l: echo idx break