N,x = list(map(int,input().split()))
A = list(map(int,input().split()))
count = 0
for a in A:
    if x >= a:
        x -= a
        count += 1
if x > 0:
    print(max(count-1,0))
else:
    print(count)