import sys
N,x=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort()
y=x
ans=0
if A[0]>y:
    print(0)
    sys.exit()
for i in range(N):
    if y<A[i]:
        break
    ans+=1
    y-=A[i]
    #print(y)
if y!=0:
    ans-=1
print(ans)