n,x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
if sum(a) < x:
    print(n-1)
elif sum(a) == x:
    print(n)
else:
    for i in a:
        if x >= i:
            cnt += 1
            x -= i
    print(cnt)
