n, x = map(int, input().split())
a = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if x >= a[i]:
        x -= a[i]
        if x > 0:
            cnt += 1
        elif x == 0:
            cnt += 1
            break

if x != 0:
    cnt -= 1

print(max(cnt, 0))
