N,x = map(int,input().split())
a = list(map(int,input().split()))
count = 0
for i in range(N):
    if(a[i]<=x):
        count+=1
        x-=a[i]
        
if(x>0):
    print(count-1)
else:
    print(count)