n, k = map(int, input().split())
arr = list(map(int, input().split()))
min_sums, min_ends = [0] * n, [0] * n
min_sums[-1] = arr[-1]
min_ends[-1] = n - 1
for i in range(n - 2, -1, -1):
if min_sums[i + 1] + arr[i] <= arr[i]:
min_sums[i] = min_sums[i + 1] + arr[i]
min_ends[i] = min_ends[i + 1]
else:
min_sums[i] = arr[i]
min_ends[i] = i
end, su, res = 0, 0, 0
for i in range(n):
while end < n and su + min_sums[end] <= k:
su += min_sums[end]
end = min_ends[end] + 1
res = max(res, end - i)
if end > i:
su -= arr[i]
else:
end = i + 1
print(res)