import strutils, sequtils, algorithm var NM, C = stdin.readLine.split.map parseInt m = NM[1] cnt = 0 C.sort(cmp) for i in 0 .. C.high: if C[i] <= m: cnt += 1 m -= C[i] else: break echo cnt