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

cnt = 0

for i in range(N-1):
    if A[i] <= x:
        x -= A[i]
        cnt += 1
        
if x == A[-1]:
    cnt += 1

print(cnt)