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

count = 0

for i in range(N):
    if a[i] <= x and i != (N-1):
        count += 1
        x -= a[i]
    elif a[i] == x and i == (N-1):
        count += 1

print(count)