# A - Candy Distribution Again
count = 0
N, x = map(int, input().split())
A = input().split()
A.sort()
for i in range(N):
    if(x == 0):
        break
    if(i == N-1):
        #最後なので全部あげる
        if(x == int(A[i])):
            count += 1
    else:
        x -= int(A[i])
        if(x >= 0):
            count += 1
print(count)