n, x = map(int, input().split())
a = list(map(int, input().split()))
answer = []
for i in range(n):
    if i == n-1:
        if x == a[i]:
            answer.append(1)
        else:
            answer.append(0)
    else:
        if x >= a[i]:
            answer.append(1)
            x -= a[i]
        else:
            answer.append(0)
print(sum(answer))