# 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]
if(sum(A_i) == x):
    print(N)
else:
    for i in range(N):
        if(i != N-1):
            x -= A_i[i]
            if(x >= 0):
                count += 1
    print(count)