N, x = map(int,input().split())
listA = [int(i) for i in input().split()]
listA.sort()
cnt = 0
X = x
for j in listA:
    if X - j < 0:
        break
    else:
        X = X - j
        cnt += 1

if X != 0 and cnt != 0:
    cnt -= 1
print(cnt)