a, b = map(int, input().split())
child = list(map(int, input().split()))
count = 0
for i in child:
    if b >= i and i != child[-1]:
        b -= i
        count += 1
    elif i == child[-1] and b == i:
        count += 1
print(count)