n, x = map(int, input().split())
a = list(map(int, input().split()))

count = 0
# for i in sorted(a):
#     if x >= i:
#         x -= i
#         count += 1
for i in range(n):
    if x >= a[i]:
        x -= a[i]
        count += 1
print(count)
