# 27

n, x = map(int, input().split())
a = list(map(int, input().split()))
num = 0
for i in range(len(a)-1):
    if x >= a[i] :
        num += 1
        x -= a[i]
if x == a[-1]:
    num += 1
print(num)