N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
cnt=0
i=0
A.append(X)
flag=0
while True:
    if A[i]<=X:
        X-=A[i]
        cnt+=1
        i+=1
        flag=1
    elif X==0:
        break
    else:
        if flag==1:
            cnt-=1
        break
print(cnt)
