N, x = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort()
answer = 0
sum = 0
for i in range(N):
    answer = i - 1
    sum += alist[i]
    if sum > x:
        break
print(answer)
