# A - Candy Distribution Again
count = 0
N, x = map(int, input().split())
A = input().split()
A.sort()
A_i = [int(s) for s in A]
for i in range(N-1):
    x -= A_i[i]
    if(x < 0):
        break
    count += 1
if(x == A_i[N-1]):
    count += 1
        
print(count)