N, X = map(int, input().split())
A = [int(x) for x in input().split()]
count = 0
def Candy (i, rest, count):

    #最後に余った
    if i == N and rest > 0:
        if count > 0:
            return count - 1
        else:
            return count

    #最後に余らなかった
    if i >= N:
        return count   
    #配って次へ
    if rest >= A[i]:
        rest -= A[i]
        count += 1
        return Candy(i+1, rest, count)

    #配らないで次へ
    
    return Candy(i+1, rest, count)

print(Candy(0, X, count))
