n, w = map(int, input().split()) A = [int(input()) for _ in range(n)] + [w + 1] ans = 0 se = set() r = 0 tot = 0 for l in range(n): while tot + A[r] <= w and A[r] not in se: se.add(A[r]) tot += A[r] r += 1 ans = max(ans, r - l) if l == r: r += 1 else: se.remove(A[l]) tot -= A[l] print(ans)