N,x=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
cnt=0
for i in range(N-1):
    if x-A[i]>=0:
        cnt+=1
        x-=A[i]
    else:
        break
if x-A[N-1]==0:
    cnt+=1

print(cnt)