
n,x= map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans= 0

X=x
for i in range(n):
    
    if 0 < X-a[i]:
        X = X-a[i]
        ans +=1
    elif X ==0:
        break

if ans == n and X >0 :
    ans -=1     
       
    
print(ans)