from itertools import accumulate
from bisect import bisect_right
n,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
S=list(accumulate(A))
i=bisect_right(S,x)
print(i if i!=n else n-1)