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)
if i==0:
    print(0)
elif S[i-1]==x:
    print(i)
else:
    print(i-1)