from bisect import bisect_right N, X = map(int, input().split()) A = list(map(int, input().split())) if sum(A) < X: exit(print(N)) if min(A) > X: exit(print(0)) acc = [0] * (2 * N + 1) for i in range(2 * N): acc[i + 1] = acc[i] + A[i % N] # print(acc) ans = 0 for i in range(N): if A[i] > X: continue r = bisect_right(acc, X + acc[i] - 1) # print(r, i) ans = max(ans, acc[r - 1] - acc[i]) print(ans)