N,X = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
count = 0
for i in A:
    if X >= i:
        X = X - i
        count += 1
    else:
        break
if X > 0:
    count -= 1
print(max(count,0))