N,x=map(int,input().split())
A=sorted(map(int,input().split()))
a=[0]*len(A)
a[0]=A[0]
count=0
for i in range(1,len(A)):
    a[i]=A[i]+a[i-1]
for i in range(len(A)):
    if a[i]<=x:
        count+=1
print(count)