from itertools import accumulate
from bisect import bisect_right

N, x, *A = map(int, open(0).read().split())

A.sort()
S = list(accumulate(A))

if S[-1] == x:
    print(N)
else:
    print(min(N - 1, bisect_right(A, x)))