from itertools import accumulate
import bisect
N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
A = list(accumulate(A))
ind = bisect.bisect_right(A,x)-1
if ind == -1:
    print(0)
elif A[ind] == x:
    print(ind+1)
else:
    print(ind)
