# 27

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

for i in range(len(a)):
    if i != len(a) - 1:
        if x >= a[i] :
            num += 1
            x -= a[i]
    elif x == a[i]:
        num += 1

print(num)