nx = input().split()
an = input().split()

n = int(nx[0])
x = int(nx[1])

count = 0

for i in range(len(an)):
    if (x >= int(an[i])):
        x = x - int(an[i])
        count += 1

if (count != 0 and x != 0):
    count -= 1
print(count)