N, M = map(int, input().split()) C = list(map(int, input().split())) C.sort() ans = 0 for c in C: if c <= M: M -= c ans += 1 print(ans)