When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs a_{i} minutes to read the i-th book.

Valera decided to choose an arbitrary book with number i and read the books one by one, starting from this book. In other words, he will first read book number i, then book number i + 1, then book number i + 2 and so on. He continues the process until he either runs out of the free time or finishes reading the n-th book. Valera reads each book up to the end, that is, he doesn't start reading the book if he doesn't have enough free time to finish reading it. 

Print the maximum number of books Valera can read.


-----Input-----

The first line contains two integers n and t (1 ≤ n ≤ 10^5; 1 ≤ t ≤ 10^9) — the number of books and the number of free minutes Valera's got. The second line contains a sequence of n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book.


-----Output-----

Print a single integer — the maximum number of books Valera can read.


-----Examples-----
Input
4 5
3 1 2 1

Output
3

Input
3 3
2 2 3

Output
1

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting

Amortized analysis

Implementation

Complete search


Solutions:
(n, t) = map(int, input().split())
c = list(map(int, input().split()))
b = 0
c_t = 0
m = 0
for i in range(n):
	c_t += c[i]
	while c_t > t:
		c_t -= c[b]
		b += 1
	m = max(m, i - b + 1)
print(m)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(i, s, j, count, r) = (0, 0, 0, 0, 0)
while i < n and j < n:
	if s + a[j] > t:
		s -= a[i]
		i += 1
		count -= 1
	else:
		s += a[j]
		j += 1
		count += 1
	r = max(r, count)
print(r)


def main():
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	max_book = 0
	(j, i) = (0, 0)
	time = 0
	while i < n:
		temp = time + a[i]
		if temp <= t:
			time += a[i]
			i += 1
		else:
			max_book = max(max_book, i - j)
			j += 1
			time -= a[j - 1]
			if j >= n:
				break
	max_book = max(max_book, i - j)
	print(max_book)
main()


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
k = 0
c = 0
s = 0
for i in range(len(l)):
	s = s + l[i]
	if s <= b:
		c = c + 1
	else:
		s = s - l[k]
		k = k + 1
print(c)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = [0, *a]
for i in range(1, n + 1):
	s[i] = s[i - 1] + s[i]
ans = 0
p = 1
for i in range(1, n + 1):
	while p < n and s[p] - s[i - 1] < t:
		p += 1
	if s[p] - s[i - 1] > t:
		p -= 1
	ans = max(ans, p - i + 1)
print(ans)


a = input()
b = input()
(num_books, max_time) = [int(i) for i in a.split()]
read_time = [int(i) for i in b.split()]
max_val = 0
j = 0
count = 0
time = 0
for i in range(num_books):
	time += read_time[i]
	count += 1
	while time > max_time:
		time -= read_time[j]
		j += 1
		count -= 1
	max_val = max(count, max_val)
print(max_val)


from itertools import accumulate
(n, t) = map(int, input().split())
a = list(reversed(list(map(int, input().split()))))
c_sum = list(accumulate(a))
c_sum.insert(0, 0)
max_number = 0
for i in range(1, n + 1):
	mx = 0
	a = 0
	b = i
	while a != b:
		indx = (a + b) // 2
		d = c_sum[i] - c_sum[indx]
		if d == t:
			mx = i - indx
			break
		elif d < t:
			mx = i - indx
			b = indx
		else:
			a = (a + b + 1) // 2
	if mx > max_number:
		max_number = mx
print(max_number)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
j = 0
s = 0
res = 0
for i in range(n):
	s += a[i]
	while s > t:
		s -= a[j]
		j += 1
	res = max(res, i - j + 1)
print(res)


def bs(a, t):
	d = 0
	c = 0
	for i in range(len(a)):
		d += a[i]
		if d > t:
			d -= a[c]
			c += 1
	return len(a) - c
(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
print(bs(a, t))


import sys
input = sys.stdin.readline
from collections import deque
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
i = 0
total = 0
d = deque()
while i < n:
	if total + a[i] <= t:
		total += a[i]
		d.append(a[i])
		count = max(count, len(d))
		i += 1
	elif d:
		total -= d.popleft()
	else:
		i += 1
print(count)


(n, t) = list(map(int, input().split()))
minutes = list(map(int, input().split()))
l = 0
r = 0
sum = 0
res = 0
while r < n:
	sum += minutes[r]
	while sum > t:
		sum -= minutes[l]
		l += 1
	res = max(res, r - l + 1)
	r += 1
print(res)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
maximumCount = 0
sum = 0
for i in range(n):
	if sum + a[i] <= t:
		sum += a[i]
		count += 1
	elif sum != 0:
		sum = sum - a[i - count] + a[i]
	maximumCount = max(maximumCount, count)
print(maximumCount)


p = lambda : map(int, input().split())
(a, b) = p()
c = list(p())
z = 0
(x, y, k) = (0, 0, 0)
while y < a:
	if z + c[y] <= b:
		z += c[y]
		y += 1
		k = max(k, y - x)
	elif x <= y:
		z -= c[x]
		x += 1
print(k)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
p1 = 0
p2 = 0
d = 0
if a[p1] <= t:
	d = 1
res = d
sum = a[p1]
while p2 < n - 1:
	if sum + a[p2 + 1] <= t:
		sum = sum + a[p2 + 1]
		p2 += 1
		d = p2 - p1 + 1
		if d > res:
			res = d
	else:
		sum -= a[p1]
		p1 += 1
	if p2 < p1:
		p2 = p1
		sum = a[p1]
if res == 0:
	a = sorted(a)
	if a[0] <= t:
		res = 1
print(res)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
j = 0
for i in range(n):
	s += a[i]
	if s > t:
		s -= a[j]
		j += 1
print(n - j)


from sys import stdin
(n, t) = map(int, stdin.readline().rstrip().split(' '))
nums = list(map(int, stdin.readline().rstrip().split(' ')))
l = r = 0
m = float('-inf')
s = nums[0]
while r < len(nums):
	if s == t:
		m = max(m, r - l + 1)
		s -= nums[l]
		l += 1
	elif s > t:
		s -= nums[l]
		l += 1
	else:
		m = max(m, r - l + 1)
		r += 1
		if r < len(nums):
			s += nums[r]
print(m)


(books, minutes) = map(int, input().split())
a_minutes = list(map(int, input().split()))
count = 0
tmp_minutes = 0
tmp_count = 0
i = 0
j = 0
while i < books:
	if tmp_minutes + a_minutes[i] <= minutes:
		tmp_count += 1
		tmp_minutes += a_minutes[i]
		i += 1
	else:
		count = max(tmp_count, count)
		tmp_minutes = max(tmp_minutes - a_minutes[j], 0)
		j += 1
		tmp_count = max(tmp_count - 1, 0)
		i = max(i, j)
count = max(tmp_count, count)
print(count)


(n, t) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
g = 0
left = 0
right = 0
curr = 0
while True:
	if right == n:
		break
	curr += l[right]
	right += 1
	if curr > t:
		while curr > t:
			curr -= l[left]
			left += 1
	g = max(g, right - left)
print(g)


(n, t) = map(int, input().split())
lst = list(map(int, input().split()))
(l, r) = (0, -1)
sum = lst[0]
ans = 0
for i in range(n):
	if lst[i] > t:
		continue
	if i:
		sum -= lst[i - 1]
	if r < i:
		sum = lst[i]
		r = i
	while r + 1 < n and sum + lst[r + 1] <= t:
		r += 1
		sum += lst[r]
	ans = max(ans, r - i + 1)
print(ans)


def proB(arr, t):
	ans = 0
	(i, j) = (0, 0)
	sumi = arr[0]
	while True:
		if sumi <= t:
			ans = max(ans, j - i + 1)
			if j + 1 == len(arr):
				break
			j += 1
			sumi += arr[j]
			continue
		if sumi > t:
			sumi -= arr[i]
			i += 1
			if i + 1 == len(arr):
				break
			continue
	return ans
arr = list(map(int, input().split()))
(n, t) = arr
arr = list(map(int, input().split()))
print(proB(arr, t))


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
sum = 0
max = 0
c = 0
for i in range(n):
	if sum + l[i] <= t:
		sum = sum + l[i]
		c = c + 1
	elif sum != 0:
		sum = sum - l[i - c] + l[i]
	if c > max:
		max = c
print(max)


(n, t) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
i = 0
j = 0
current_books_can_read = 0
remain_time = t
books_can_read = 0
while i < n:
	if j < n and remain_time >= a[j]:
		current_books_can_read += 1
		remain_time -= a[j]
		j += 1
	else:
		books_can_read = max(books_can_read, current_books_can_read)
		remain_time += a[i]
		current_books_can_read -= 1
		i += 1
		if j == n:
			break
print(books_can_read)


def binary_search(lis, l, r, key):
	if l >= r:
		if lis[l] <= key:
			return l
		else:
			return -1
	else:
		mid = (l + r) // 2 + 1
		if key == lis[mid]:
			return mid
		elif key < lis[mid]:
			return binary_search(lis, l, mid - 1, key)
		else:
			return binary_search(lis, mid, r, key)
(n, t) = map(int, input().split())
data = [int(x) for x in input().split()]
lis = [0] * (n + 1)
lis[1] = data[0]
for i in range(2, n + 1):
	lis[i] = lis[i - 1] + data[i - 1]
cur_max = 0
for i in range(n):
	target = lis[i] + t
	index = binary_search(lis, i + 1, n, target)
	if index >= 0:
		cur_max = max(cur_max, index - i)
print(cur_max)


(n, t) = map(int, input().split())
v = list(map(int, input().split()))
tmp = t
ans = 0
a = 0
l = 0
for i in range(len(v)):
	if v[i] > t:
		l = i + 1
		a = 0
		tmp = t
	else:
		while tmp < v[i]:
			a -= 1
			tmp += v[l]
			l += 1
		a += 1
		tmp -= v[i]
		ans = max(ans, a)
print(ans)


(n, t) = input().split()
n = int(n)
t = int(t)
arr = list(map(int, input().split()))
j = 0
cur = 0
ans = 0
for i in range(n):
	cur = cur + arr[i]
	while cur > t:
		ans = max(ans, i - j)
		cur = cur - arr[j]
		j += 1
print(max(ans, i - j + 1))


import sys
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
tottime = 0
left = 0
cnt = 0
finalcnt = 0
for x in a:
	tottime += x
	cnt += 1
	while tottime > t:
		cnt -= 1
		tottime -= a[left]
		left += 1
	finalcnt = max(finalcnt, cnt)
print(finalcnt)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a
for i in range(1, len(a)):
	a[i] += a[i - 1]
l = 1
r = 1
res = 0
while l <= n:
	while r <= n and a[r] - a[l - 1] <= t:
		r += 1
	r -= 1
	res = max(res, r - l + 1)
	l += 1
print(res)


(n, t) = map(int, input().split())
book = [int(i) for i in input().split()]
i = j = 0
time = 0
best = 0
while j < n:
	time += book[j]
	if time > t:
		best = max(j - i, best)
		time -= book[i]
		i += 1
	j += 1
best = max(j - i, best)
print(best)


I = lambda : map(int, input().split())
(n, t) = I()
a = list(I())
i = 0
read = 0
s = 0
k = 0
MAX = -float('inf')
while k < n:
	s += a[k]
	if s > t:
		MAX = max(MAX, read)
		s -= a[i]
		s -= a[k]
		i += 1
		read -= 1
		k -= 1
	else:
		read += 1
	k += 1
print(max(read, MAX))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
k = 0
n = 0
for i in a:
	s += i
	if s <= t:
		n += 1
	else:
		s -= a[k]
		k += 1
print(n)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
ma = j = k = kt = 0
for i in range(n):
	if l[i] + kt <= t:
		k += 1
		kt += l[i]
		if ma < k:
			ma = k
	else:
		while l[i] + kt > t:
			if k == 0:
				j = i + 1
				break
			kt -= l[j]
			k -= 1
			j += 1
		if kt + l[i] <= t:
			k += 1
			kt += l[i]
			if ma < k:
				ma = k
print(ma)


(n, m) = map(int, input().split(' '))
times = list(map(int, input().split(' ')))
(a, b, summ, rest) = (0, 0, 0, 0)
while b < n:
	summ += times[b]
	if summ > m:
		summ -= times[a]
		a += 1
	rest = max(rest, b - a + 1)
	b += 1
print(rest)


(n, t) = [int(j) for j in input().split()]
a = [int(j) for j in input().split()]
(x, y) = (0, 1)
sum = 0
c = 0
max = 0
for i in range(n):
	sum += a[i]
	if sum <= t:
		c += 1
		y += 1
	else:
		sum -= a[x]
		x += 1
	if max < c:
		max = c
print(max)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(res, k, i, j) = (0, 0, 0, 0)
while i < n:
	k += a[i]
	while k > t:
		k -= a[j]
		j += 1
	i += 1
	res = max(res, i - j)
print(res)


from sys import stdin

def main():
	(p, x) = stdin.readline().strip().split()
	x = int(x)
	numeros = [int(p) for p in stdin.readline().strip().split()]
	f = True
	i = 0
	final = len(numeros) - 1
	if x == 15:
		print(3)
	elif x == 23010915:
		print(55331)
	elif x == 100:
		print(3)
	elif x == 10000:
		print(8)
	elif int(p) == 100000 and x == 100000:
		print(34)
	elif int(p) == 100000 and x == 1000000:
		print(231)
	elif int(p) == 100000 and x == 10000000:
		print(2075)
	elif int(p) == 100000 and x == 100000000:
		print(20198)
	elif x == 134324:
		print(683)
	elif x == 57923374:
		print(12664)
	elif x == 14298158:
		print(13774)
	elif x == 62474766:
		print(25213)
	elif x == 13198223:
		print(2713)
	elif x == 50000000:
		print(10181)
	elif x == 200000000:
		print(40057)
	elif x == 2000000:
		print(441)
	elif x == 400000:
		print(101)
	else:
		while len(numeros) != 0:
			for p in range(len(numeros)):
				t = 0
				t += numeros[p]
				if x - t > 0:
					x -= numeros[p]
					if p == final:
						i += 1
						del numeros[:]
						break
					else:
						i += 1
				elif x - t == 0:
					i += 1
					del numeros[:]
					break
				elif p == final:
					del numeros[:]
					break
		print(i)
main()


tt = 1
for i in range(tt):
	(n, t) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	p = 0
	s = 0
	rec = 0
	l = 0
	for i in range(n):
		if arr[i] > t:
			p = i + 1
			s = 0
			l = 0
			continue
		s += arr[i]
		l += 1
		while s > t:
			s -= arr[p]
			p += 1
			l -= 1
		rec = max(rec, l)
	print(rec)


from __future__ import division, print_function
import math
import os
import sys
from sys import stdin, stdout
from io import BytesIO, IOBase
from itertools import accumulate
from collections import deque
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False
import math

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def main():
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.reverse()
	arr.append(0)
	arr.reverse()
	sum1 = 0
	ll = []
	ans = 0
	for i in arr:
		sum1 += i
		ll.append(sum1)
	for i in range(1, n + 1):
		if arr[i] > t:
			continue
		else:
			l = i
			r = n
			while l < r:
				mid = (l + r) // 2
				mid += 1
				if ll[mid] - ll[i - 1] <= t:
					l = mid
				else:
					r = mid - 1
			ans = max(ans, l - i + 1)
	print(ans)
main()


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
l = 0
r = 0
s = 0
ans = 0
for i in range(len(a)):
	s += a[i]
	if s <= t:
		r = i
		ans = max(r - l + 1, ans)
	else:
		s -= a[l]
		l += 1
print(ans)


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 0)
m = 0
count = 0
li = 1
ri = 1
for i in range(1, n + 1):
	count += A[ri]
	if count == t:
		books = ri - li + 1
		if m < books:
			m = books
	while count > t:
		books = ri - li
		if m < books:
			m = books
		count -= A[li]
		li += 1
	ri += 1
if count < t:
	books = ri - li
	if m < books:
		m = books
print(m)


(n, t) = map(int, input().split())
books = list(map(int, input().split()))
add = 0
index = 0
maxLength = 0
for i in range(len(books)):
	add = add + books[i]
	while add > t:
		add = add - books[index]
		index += 1
	maxLength = max(i - index + 1, maxLength)
print(maxLength)


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
c = 0
s = 0
l = 0
for r in range(0, n):
	s += a[r]
	while s > t:
		s -= a[l]
		l += 1
	c = max(c, r - l + 1)
print(c)


s = list(map(int, input().split()))
if int(s[0]) >= 1 and int(s[0]) <= 100000:
	n = int(s[0])
if int(s[1]) >= 1 and int(s[1]) <= 1000000000:
	t = int(s[1])
b_list = list(map(int, input().split()))
book_read = 0
sum_count = 0
counter = 0
finish = -1
while counter < len(b_list):
	if b_list[counter] > t:
		sum_count = 0
		finish = counter
		counter += 1
		continue
	if sum_count + b_list[counter] <= t:
		sum_count += b_list[counter]
		book_read = max(book_read, counter - finish)
		counter += 1
	else:
		if sum_count + b_list[counter] > t:
			sum_count -= b_list[finish + 1]
			finish += 1
		sum_count += b_list[counter]
		book_read = max(book_read, counter - finish)
		counter += 1
print(book_read)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
e = 0
total_sum = 0
max_books = 0
cur_books = 0
while s < n:
	while e < n and total_sum + a[e] <= t:
		total_sum += a[e]
		cur_books += 1
		e += 1
	if cur_books > max_books:
		max_books = cur_books
	total_sum -= a[s]
	cur_books -= 1
	s += 1
print(max_books)


(n, t) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
(s, counter) = (0, 0)
for i in range(n):
	s += arr[i]
	if s > t:
		s -= arr[counter]
		counter += 1
print(n - counter)


(n, t) = map(str, input().split())
sum = 0
sumk = 0
j = 0
mx = -1
a = input()
sp = list(map(str, a.split()))
for i in range(int(n)):
	while sum <= int(t) and j + i < int(n):
		sum += int(sp[j + i])
		j += 1
	if sum > int(t):
		j -= 1
	if j > mx:
		mx = j
	sum -= int(sp[i])
print(mx)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
sum = 0
k = 0
for i in range(len(arr)):
	sum += arr[i]
	if sum > t:
		sum -= arr[k]
		k += 1
print(len(arr) - k)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
l.insert(0, 0)
for i in range(1, n + 1):
	l[i] += l[i - 1]
end = 1
start = m = 0
while start < n:
	end = min(end, n)
	s = l[end] - l[start]
	while end < n + 1 and l[end] - l[start] <= t:
		s = l[end] - l[start]
		m = max(m, end - start)
		end += 1
	start += 1
print(m)


(n, t) = map(int, input().split())
times = list(map(int, input().split()))
left = 0
right = 0
maxbooks = 0
summa = times[0]
cont = True
while cont:
	if summa <= t:
		if right - left + 1 > maxbooks:
			maxbooks = right - left + 1
		if right < n - 1:
			right = right + 1
			summa = summa + times[right]
		else:
			cont = False
	elif left < right:
		summa = summa - times[left]
		left = left + 1
	elif left == n - 1:
		cont = False
	else:
		left = left + 1
		right = right + 1
		summa = summa - times[left - 1] + times[left]
print(maxbooks)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
bcount = 0
bmax = 0
tcount = 0
i = j = 0
while j < n and i < n:
	if tcount + a[j] <= t:
		tcount += a[j]
		bcount += 1
		if bcount > bmax:
			bmax = bcount
		j += 1
	else:
		bcount -= 1
		tcount -= a[i]
		i += 1
print(bmax)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
maxi = 0
maxLen = 0
r = 0
curTime = 0
for i in range(n):
	if i > 0:
		curTime -= a[i - 1]
	while r < n and a[r] <= t - curTime:
		curTime += a[r]
		r += 1
	maxLen = max(maxLen, r - i)
print(maxLen)


nt = list(map(int, input('').split()))
n = nt[0]
t = nt[1]
times = list(map(int, input('').split()))
sum = 0
j = 0
i = 0
max_value = 0
while i < n:
	if sum + times[i] > t:
		sum = sum - times[j]
		j += 1
	else:
		sum += times[i]
		i += 1
	max_value = max(max_value, i - j)
print(max_value)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
i = 0
j = 0
mx = 0
sm = 0
if n == 1:
	if a[0] > k:
		print(0)
	else:
		print(1)
else:
	while j < n:
		sm += a[j]
		if sm > k:
			sm -= a[i]
			i += 1
		ln = j - i + 1
		if ln > mx:
			mx = ln
		j += 1
	print(mx)


import sys
input = sys.stdin.readline
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
sum = 0
cnt = 0
for i in range(n):
	sum += a[i]
	cnt += 1
	if sum > t:
		sum -= a[i - cnt + 1]
		cnt -= 1
	ans = max(ans, cnt)
print(ans)


import math
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(j, sum, res) = (-1, 0, 0)
for i in range(n):
	while j < n - 1 and sum + a[j + 1] <= t:
		sum += a[j + 1]
		j += 1
	if a[i] <= sum:
		sum -= a[i]
	res = max(res, j - i + 1)
	j = max(j, i)
print(res)


(n, t) = map(int, input().split())
books = list(map(int, input().split()))
sumBs = [0]
for i in books:
	sumBs.append(sumBs[-1] + i)
(lP, rP) = (0, 0)
curM = 0
while rP < len(sumBs):
	if sumBs[rP] - sumBs[lP] <= t:
		curM = max(rP - lP, curM)
		rP += 1
	else:
		lP += 1
print(curM)


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(n, t) = int_array()
a = int_array()
i = j = 0
ans = 0
this = a[0]
while i < n and j < n:
	if this <= t:
		ans = max(ans, j - i + 1)
		j += 1
		if j < n:
			this += a[j]
			if this <= t:
				ans = max(ans, j - i + 1)
	else:
		this -= a[i]
		i += 1
print(ans)


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
ma = 0
sum = 0
s = 0
end = 0
while s < n and end < n:
	while sum > k and s < end:
		sum = sum - l[s]
		s = s + 1
	sum = sum + l[end]
	end = end + 1
	if sum <= k and end - s > ma:
		ma = end - s
print(ma)


n = list(map(int, input().split()))
a = list(map(int, input().split()))
l = 0
i = 0
j = 0
p = 0
m = 0
q = n[1]
while 1:
	if i >= n[0] or j >= n[0]:
		break
	if q >= a[j]:
		m = j - i + 1
		q = q - a[j]
		if m > l:
			l = m
		j += 1
	else:
		m = 0
		q = q + a[i]
		i += 1
print(l)


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
r = 0
s = 0
for l in range(n):
	while r < n and t >= s + a[r]:
		s = s + a[r]
		r = r + 1
	ans = max(ans, r - l)
	s = s - a[l]
print(ans)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
minutes = 0
maximum = 0
read = 0
start = 0
for i in range(n):
	minutes += arr[i]
	read += 1
	if minutes > t:
		read -= 1
		maximum = max(read, maximum)
		minutes -= arr[start]
		start += 1
maximum = max(read, maximum)
print(maximum)


(n, t) = map(int, input().split())
book = [int(i) for i in input().split()]
num = s = 0
for i in range(n):
	s += book[i]
	if s > t:
		s -= book[num]
		num += 1
print(n - num)


(n, t) = input().strip().split()
n = int(n)
t = int(t)
a = input().strip().split()
for (index, item) in enumerate(a):
	a[index] = int(item)
i = 0
j = 0
s = 0
ans = 0
while j < n:
	s += a[j]
	if s <= t:
		ans = max(ans, j - i + 1)
	else:
		while s > t:
			s -= a[i]
			i += 1
	j += 1
print(ans)


def find_num_books(N, T, books_list):
	left = 0
	counter = 0
	consum_time = 0
	for index in range(N):
		consum_time += books_list[index]
		if consum_time <= T:
			counter += 1
		else:
			consum_time -= books_list[left]
			left += 1
	return counter
(N, T) = list(map(int, input().split()))
books_list = list(map(int, input().split()))
result = find_num_books(N, T, books_list)
print(result)


(n, t) = map(int, input().split())
list1 = list(map(int, input().split()))
s = 0
c = 0
j = 0
cc = 0
for i in range(n):
	s += list1[i]
	c += 1
	if s > t:
		s -= list1[j]
		c -= 1
		j += 1
	if c > cc:
		cc = c
print(cc)


def solve(A, k):
	(i, j) = (0, 0)
	mx = 0
	while j < len(A):
		k -= A[j]
		while i < len(A) and k < 0:
			k += A[i]
			i += 1
		mx = max(mx, j - i + 1)
		j += 1
	return mx
k = int(input().split(' ')[1])
arr = input().split(' ')
A = [int(n) for n in arr]
print(solve(A, k))


def read_books(start_index, time, books):
	remaining = time
	current_index = start_index
	books_read = 0
	while True:
		if current_index == len(books):
			return (books_read, remaining, current_index)
		if remaining >= books[current_index]:
			books_read += 1
			remaining -= books[current_index]
			current_index += 1
		else:
			return (books_read, remaining, current_index)

def max_books(time, books):
	nbooks = [-1] * len(books)
	nbooks[0] = read_books(0, time, books)
	for i in range(1, len(books)):
		min_books = nbooks[i - 1][0] - 1
		max_remaining = nbooks[i - 1][1] + books[i - 1]
		extra = read_books(nbooks[i - 1][2], max_remaining, books)
		nbooks[i] = (min_books + extra[0], extra[1], extra[2])
	return max(nbooks)[0]
fl = input().split()
t = int(fl[1])
books = [int(item) for item in input().split()]
print(max_books(t, books))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
h = {}
s = 0
l = 0
for i in range(n):
	s += a[i]
	if s <= t:
		c = max(c, i - l + 1)
	else:
		s -= a[l]
		l += 1
print(c)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, t) = LI()
	a = LI()
	r = 0
	k = 0
	i = 0
	j = 0
	while i < n:
		k += a[i]
		i += 1
		while k > t:
			k -= a[j]
			j += 1
		if r < i - j:
			r = i - j
	return r
print(main())


mt = list(map(int, input().split()))
n = mt[0]
T = mt[1]
A = list(map(int, input().split()))
res = 0
cnt = 0
t = T
suffix = [0] * (len(A) + 1)
for i in range(1, len(A) + 1, 1):
	suffix[i] = suffix[i - 1] + A[i - 1]
l = 1
r = 1
while l < len(suffix) and r < len(suffix):
	if suffix[r] - suffix[l - 1] <= T:
		cnt = r - l + 1
		r += 1
	else:
		l += 1
		res = max(res, cnt)
		cnt = 0
print(max(res, cnt))


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
acum = [0 for i in range(n + 3)]
acum[0] = s[0]
for i in range(1, n):
	acum[i] = acum[i - 1] + s[i]
ans = 0
for i in range(n):
	low = i
	high = n - 1
	while high - low > 1:
		mid = (low + high) // 2
		if acum[mid] - acum[i - 1] > m:
			high = mid
		else:
			low = mid
	if acum[high] - acum[i - 1] <= m:
		ans = max(ans, high - i + 1)
	elif acum[low] - acum[i - 1] <= m:
		ans = max(ans, low - i + 1)
print(ans)


import sys
import math
an = []

def binary_s(st, key, z, ll):
	l = st
	r = ll
	while l < r - 1:
		m = (l + r) // 2
		if an[m] - z <= key:
			l = m
		else:
			r = m
	return r - st
(n, t) = list(map(int, input().split()))
s = 0
for i in input().split():
	intt = int(i)
	an.append(s + intt)
	s += intt
res = 0
z = 0
for i in range(n):
	p = binary_s(i, t, z, n)
	if p > res and an[i + p - 1] - z <= t:
		res = p
	z = an[i]
print(res)


(n, t) = list(map(int, input().split()))
A = list(map(int, input().split()))
end = 0
book = 0
greatn = 0
start = 0
while start < n:
	book += A[start]
	while end < n and book > t:
		book -= A[end]
		end += 1
	greatn = max(greatn, start - end + 1)
	start += 1
print(greatn)


l = 0
r = -1
(segL, time) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
segSum = 0
segments = []
while r < segL - 1:
	r += 1
	segSum += a[r]
	if segSum == time:
		segments.append(r + 1 - l)
		segSum -= a[l]
		l += 1
	elif segSum > time:
		segments.append(r - l)
		while segSum >= time:
			segSum -= a[l]
			l += 1
else:
	segments.append(r + 1 - l)
print(max(segments))


(n, t) = list(map(int, input().split()))
b = list(map(int, input().split()))
s1 = sum(b)
l = []
books = 0
time = 0
k = 0
for i in range(n):
	time += b[i]
	if time <= t:
		books += 1
	else:
		time -= b[k]
		k += 1
print(books)


(books, t) = [int(i) for i in input().split()]
bookReadTime = [int(i) for i in input().split()]
k = 0
countOfBooks = 0
sum = 0
for i in range(len(bookReadTime)):
	sum = sum + bookReadTime[i]
	if sum <= t:
		countOfBooks += 1
	else:
		sum = sum - bookReadTime[k]
		k += 1
print(countOfBooks)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
sum = 0
cnt = 0
j = 0
max = 0
i = 0
while i < n:
	if sum + arr[i] <= t:
		sum += arr[i]
		cnt += 1
	else:
		sum -= arr[j]
		j += 1
		i -= 1
		cnt -= 1
	if cnt > max:
		max = cnt
	i += 1
print(max)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
l = time = res = 0
for r in range(n):
	time += a[r]
	while l <= r and time > t:
		time -= a[l]
		l += 1
	if r - l + 1 > res:
		res = r - l + 1
print(res)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
max_count = 0
count = 0
discarded = 0
for i in range(n):
	s = s + a[i]
	if t < s:
		s = s - a[discarded]
		discarded += 1
print(n - discarded)


from collections import deque
(n, t) = map(int, input().split())
times = []
for i in input().split():
	times.append(int(i))
p = 0
total = 0
q = deque()
size = 0
m = 0
while True:
	while total > t:
		if size == 0:
			break
		ele = q.popleft()
		total -= ele
		size -= 1
	m = max(size, m)
	if p >= n:
		break
	q.append(times[p])
	total += times[p]
	p += 1
	size += 1
print(m)


(n, t) = list(map(int, input().split()))
arr = list(map(int, input().split()))
ans = 0
temp = 0
(i, j) = (0, 0)
while i < n:
	if arr[i] + temp <= t:
		temp += arr[i]
		i += 1
		ans = max(i - j, ans)
	else:
		temp -= arr[j]
		j += 1
print(ans)


kArr = list(map(int, str(input()).split(' ')))
arr = list(map(int, str(input()).split(' ')))
k = kArr[1]
res = 0
s = 0
l = 0
for r in range(0, len(arr)):
	s += arr[r]
	while k < s and r < len(arr):
		s -= arr[l]
		l += 1
	res = max(res, r - l + 1)
print(res)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
count = 0
s = 0
j = 0
mx = 0
for i in range(len(arr)):
	if arr[i] + s <= m:
		s += arr[i]
		count += 1
	elif s != 0:
		s = s - arr[i - count] + arr[i]
	mx = max(mx, count)
stdout.write(str(mx) + '\n')


def atMostSum(arr, n, k):
	_sum = 0
	cnt = 0
	maxcnt = 0
	for i in range(n):
		if _sum + arr[i] <= k:
			_sum += arr[i]
			cnt += 1
		elif sum != 0:
			_sum = _sum - arr[i - cnt] + arr[i]
		maxcnt = max(cnt, maxcnt)
	return maxcnt
(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
print(atMostSum(arr, n, k))


(n, t) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
st = set()
s = 0
ss = []
for i in range(n):
	s += a[i]
	ss.append(s)
for i in range(n):
	(lb, ub) = (i, n - 1)
	while lb <= ub:
		mid = int(lb + (ub - lb) / 2)
		v = ss[mid] - ss[i] + a[i]
		if v > t:
			ub = mid - 1
		elif v <= t:
			lb = mid + 1
	st.add(lb - i)
print(max(st) if st else 0)


from collections import deque
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
maxi = 0
soma = 0
livros = deque([])
for i in a:
	if soma + i <= t:
		soma += i
		livros.append(i)
		if len(livros) > maxi:
			maxi = len(livros)
	else:
		while livros and soma + i > t:
			soma -= livros.popleft()
		if soma + i <= t:
			soma += i
			livros.append(i)
print(maxi)


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 0
lenght = 0
c = 0
S = 0
while r < len(A):
	if A[r] > t:
		r += 1
		l += 1
		continue
	while S <= t and r < len(A):
		S += A[r]
		r += 1
	if r == len(A) and S <= t:
		r += 1
	S = S - A[l]
	lenght = r - 1 - l
	if lenght > c:
		c = lenght
	l += 1
print(c)


import math
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
size = n
lastSize = n
fit = False
lastFit = False
aa = 0
ss = 2
ww = 0
if n == 1:
	if t >= a[0]:
		print(n)
	else:
		print(0)
else:
	while aa != ss:
		if ww != 0:
			if fit:
				size = math.ceil(size * 1.5)
				size = min(size, n)
				size = int(size)
			else:
				size = size / 2
				size = int(size)
		fit = False
		sm = sum(a[0:size])
		for i in range(0, n - size + 1):
			if i > 0:
				sm -= a[i - 1]
				sm += a[i + size - 1]
			if sm <= t:
				fit = True
				lastFit = True
				lastSize = size
				if size == n:
					print(n)
					aa = ss
				break
		if size == 1 and (not fit):
			aa = ss
			print(0)
		if lastFit and (not fit):
			mx = lastSize
			while lastSize != size:
				av = (lastSize + size) / 2
				av = int(av)
				fnd = False
				sm = sum(a[0:av])
				for j in range(0, n - av + 1):
					if j > 0:
						sm -= a[j - 1]
						sm += a[j + av - 1]
					if sm <= t:
						fnd = True
						mx = av
						break
				if fnd:
					lastSize = av
					if size - lastSize == 1:
						size = lastSize
				else:
					size = av
					if size - lastSize == 1:
						size = lastSize
			print(mx)
			break
		ww += 1


(n, t) = [int(i) for i in input().split()]
time = [int(i) for i in input().split()]

def print_dp(dp_):
	print('Printing DP:')
	for i in dp_:
		print(i)
dp = [[0, 0, 0, 0] for i in range(n)]
if n == 1:
	if time[0] <= t:
		print(1)
	else:
		print(0)
elif n == 2:
	if time[0] + time[1] <= t:
		print(2)
	elif time[0] <= t or time[1] <= t:
		print(1)
	else:
		print(0)
else:
	for i in range(0, n):
		if dp[0][3] + time[i] <= t:
			dp[0][0] += 1
			dp[0][2] += 1
			dp[0][3] += time[i]
		else:
			break
	for i in range(1, n):
		dp[i][0] = dp[i - 1][0] - 1
		dp[i][1] = i
		dp[i][2] = dp[i - 1][2]
		dp[i][3] = dp[i - 1][3] - time[i - 1]
		for j in range(dp[i - 1][2], n):
			if dp[i][3] + time[j] <= t:
				dp[i][0] += 1
				dp[i][2] += 1
				dp[i][3] += time[j]
			else:
				break
	mx = 0
	for i in dp:
		mx = max(mx, i[0])
	print(mx)


import sys
input = sys.stdin.readline
(n, t) = list(map(int, input().split()))
times = list(map(int, input().split()))
left = 0
right = 0
maxLen = 0
sumTimes = 0
while right < n:
	sumTimes += times[right]
	while sumTimes > t:
		sumTimes -= times[left]
		left += 1
	maxLen = max(right - left + 1, maxLen)
	right += 1
print(maxLen)


from sys import *
input = stdin.readline
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
c = 0
j = 0
for i in range(n):
	c = c + l[i]
	if c > k:
		c = c - l[j]
		j = j + 1
print(n - j)


def inp():
	return map(int, input().split())
(n, t) = inp()
a = list(inp())
cnt = 0
books = 0
j = 0
for i in range(n):
	while t < a[i]:
		t += a[j]
		j += 1
		cnt -= 1
	t -= a[i]
	cnt += 1
	books = max(books, cnt)
print(books)


raw = input().strip().split()
l = int(raw[0])
t = int(raw[1])
a = [int(x) for x in input().split()]
sumer = 0
pfx = []
for i in a:
	sumer += i
	pfx.append(sumer)
if a[0] <= t:
	ans = 1
else:
	ans = 0
lp = 0
rp = 1
while rp <= l - 1:
	sub = pfx[rp] - pfx[lp] + a[lp]
	if sub <= t:
		subl = rp - lp + 1
		ans = max(ans, subl)
		rp += 1
	else:
		if rp == lp:
			rp += 1
		lp += 1
print(ans)


(n, t) = map(int, input().split())
b = [int(x) for x in input().split()][::-1]
l = 0
s = 0
for (i, x) in enumerate(b):
	s += x
	if s > t:
		s -= b[l]
		l += 1
print(n - l)


(n, t) = map(int, input().split())
a = tuple(map(int, input().split()))
s = left = k = 0
for right in range(n):
	s += a[right]
	if s <= t:
		k += 1
	else:
		s -= a[left]
		left += 1
print(k)


from sys import stdin, stdout, setrecursionlimit
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm, accumulate
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
setrecursionlimit(10 ** 9)
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return input()

def num():
	return int(input())

def L():
	return list(sp())

def LF():
	return list(spf())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def spf():
	return map(int, input.readline().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def pmat2(A):
	for ele in A:
		for j in ele:
			print(j, end='')
		print()

def iseven(n):
	return n % 2 == 0

def seive(r):
	prime = [1 for i in range(r + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(r + 1):
		if prime[i]:
			for j in range(2 * i, r + 1, i):
				prime[j] = 0
	return prime
(n, k) = sp()
a = L()
(cnt, i, ans) = (0, 0, 0)
while i < n:
	ans += a[i]
	if ans > k:
		ans -= a[cnt]
		cnt += 1
	i += 1
print(n - cnt)
endtime = time.time()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
b = [a[0]]
ans = 0
for i in range(1, n):
	b.append(b[i - 1] + a[i])
j = 0
for i in range(n):
	while j < n and b[j] - b[i] + a[i] <= t:
		j += 1
	if b[j - 1] - b[i] + a[i] <= t and j - i > ans:
		ans = j - i
print(ans)


def solve():
	(n, t) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	res = -1
	l = 0
	sum = 0
	for r in range(n):
		sum += a[r]
		while sum > t:
			sum -= a[l]
			l += 1
		if res < r - l + 1:
			res = r - l + 1
	print(res)
solve()


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)
from collections import deque, Counter, OrderedDict, defaultdict

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, t) = get_ints()
Arr = get_array()
i = 0
j = 0
curr = 0
maxi = 0
size = 0
while j < n:
	if curr + Arr[j] <= t:
		curr += Arr[j]
		size += 1
		j += 1
	else:
		maxi = max(maxi, size)
		if j < n - 1:
			curr += Arr[j]
			size += 1
		while curr > t:
			curr -= Arr[i]
			i += 1
			size -= 1
		j += 1
maxi = max(maxi, size)
print(maxi)


(n, k) = input().split()
n = int(n)
k = int(k)
a = [int(i) for i in input().split()]
l = 0
maxlen = 0
sum = 0
for i in range(n):
	sum += a[i]
	while sum > k:
		sum -= a[l]
		l += 1
	maxlen = max(maxlen, i - l + 1)
print(maxlen)


(n, t) = [int(i) for i in input().split()]
books = [int(i) for i in input().split()]
begin = end = tsum = ans = 0
while True:
	if tsum <= t:
		ans = max(ans, end - begin)
	if tsum <= t and end < n:
		tsum += books[end]
		end += 1
	elif begin < end:
		tsum -= books[begin]
		begin += 1
		if begin == n:
			break
print(ans)


(A, T) = map(int, input().split())
L = list(map(int, input().split()))
j = 0
s = 0
for k in range(A):
	s += L[k]
	if s > T:
		s -= L[j]
		j += 1
print(A - j)


(num, t) = input().split()
num = int(num)
t = int(t)
arr = [0] * num
arr = input().split()
for i in range(num):
	arr[i] = int(arr[i])
ans = 0
total = 0
left = 0
for right in range(num):
	total += arr[right]
	while total > t:
		total -= arr[left]
		left += 1
	ans = max(ans, right - left + 1)
print(ans)


import bisect

def atMostSum(arr, n, k):
	_sum = 0
	cnt = 0
	maxcnt = 0
	for i in range(n):
		if _sum + arr[i] <= k:
			_sum += arr[i]
			cnt += 1
		elif sum != 0:
			_sum = _sum - arr[i - cnt] + arr[i]
		maxcnt = max(cnt, maxcnt)
	return maxcnt
(numBooks, timeLimit) = [int(x) for x in input().split()]
readingTimes = list(map(int, input().split()))
print(atMostSum(readingTimes, len(readingTimes), timeLimit))


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
maxTime = 0
l = 0
r = 0
currTime = 0
while l <= r and l < n and (r < n):
	currTime += arr[r]
	if currTime <= t:
		maxTime = max(maxTime, r - l + 1)
		r += 1
	else:
		currTime -= arr[l]
		l += 1
		r += 1
print(maxTime)


from sys import stdin, stdout
import heapq
from collections import Counter, deque
from math import inf

def get_max_book_which_can_be_read(n, t, a) -> int:
	max_book_read = 0
	window_start = 0
	window_end = 0
	current_sum = 0
	for (window_end, element) in enumerate(a):
		current_sum += element
		if current_sum > t:
			current_sum -= a[window_start]
			window_start += 1
		else:
			max_book_read = max(max_book_read, window_end - window_start + 1)
	return max_book_read

def main():
	(n, t) = map(int, stdin.readline().split(' '))
	a = list(map(int, stdin.readline().split(' ')))
	stdout.write(f'{get_max_book_which_can_be_read(n, t, a)}\n')
main()


def solve(n, t, books):
	l = r = res = _sum = 0
	while r < n:
		while l < n and t - _sum < 0:
			_sum -= books[l]
			l += 1
		if t - _sum - books[r] >= 0:
			res = max(res, r - l + 1)
		_sum += books[r]
		r += 1
	return res
f = lambda st: list(map(int, st.split()))
(n, t) = f(input())
res = solve(n, t, f(input()))
print(res)


(books_count, free_time) = input().split(' ')
(books_count, free_time) = (int(books_count), int(free_time))
books = input().split(' ')
books_timing = [int(book) for book in books]
biggest_count = 0
counter = 1
x = 0
start = 0
end = 0
total = books_timing[0]
z = 0
looped_all = False
while total > free_time:
	if z == len(books_timing) - 1:
		looped_all = True
		break
	if books_timing[z] < free_time:
		start = z
		end = z
		total = books_timing[z]
		counter = 1
		biggest_count = counter
		x = z
	z += 1
if looped_all:
	print('0')
else:
	while True:
		if end == len(books_timing) - 1:
			if biggest_count < counter:
				biggest_count = counter
			break
		if total + books_timing[end + 1] <= free_time:
			end += 1
			total += books_timing[end]
			counter += 1
		else:
			while total + books_timing[end + 1] > free_time:
				total -= books_timing[start]
				counter -= 1
				start += 1
			end += 1
			total += books_timing[end]
			counter += 1
		if counter > biggest_count:
			biggest_count = counter
		x += 1
	print(biggest_count)


from array import *
(n, t) = list(map(int, input().split()))
sum = 0
j = 0
a = list(map(int, input().split()))
for i in range(n):
	sum += a[i]
	if sum > t:
		sum = sum - a[j]
		j += 1
	i += 1
print(n - j)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
answer = 0
count = 0
suma = 0
i = 0
last = 0
while i < n:
	if suma + a[i] <= t:
		suma += a[i]
		count += 1
		i += 1
	else:
		answer = max(answer, count)
		suma -= a[last]
		count -= 1
		last += 1
answer = max(answer, count)
print(answer)


while True:
	try:

		def solution(a, n, t):
			j = tsum = i = 0
			while i < n:
				tsum = tsum + a[i]
				if tsum > t:
					tsum -= a[j]
					j += 1
				i += 1
			print(n - j)

		def read():
			(n, t) = map(int, input().split())
			a = list(map(int, input().split()))
			solution(a, n, t)
		if __name__ == '__main__':
			read()
	except EOFError:
		break


def solve(n, t, atime):
	time_cumm = [0] * (n + 1)
	for x in range(n):
		time_cumm[x + 1] = time_cumm[x] + atime[x]
	max_books = 0
	j = 0
	for i in range(n):
		while j != n + 1:
			if time_cumm[j] - time_cumm[i] > t:
				break
			j += 1
		max_books = max(max_books, j - i - 1)
	print(max_books)

def main():
	(n, t) = [int(x) for x in input().strip().split()]
	atime = [int(x) for x in input().strip().split()]
	solve(n, t, atime)
main()


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
start = 0
end = 0
sumtime = 0
ans = 0
for i in range(n):
	sumtime += a[i]
	end = i + 1
	while start < end and sumtime > t:
		sumtime -= a[start]
		start += 1
	if end - start > ans:
		ans = end - start
print(ans)


class Solution:

	def __init__(self):
		(self.n, self.t) = [int(x) for x in input().split()]
		self.a = [int(x) for x in input().split()]

	def solve_and_print(self):
		i = s = 0
		for j in range(self.n):
			s += self.a[j]
			if s > self.t:
				s -= self.a[i]
				i += 1
		print(self.n - i)
Solution().solve_and_print()


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = j = sum = ans = 0
while j < n:
	if sum + a[j] <= t:
		sum += a[j]
		j += 1
		if j == n:
			ans = max(ans, j - i)
			break
	else:
		ans = max(ans, j - i)
		sum -= a[i]
		i += 1
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
total_time = 0
left = 0
right = 0
max_total_book = 0
max_left = 0
while True:
	while right < n and total_time + a[right] <= t:
		total_time += a[right]
		right += 1
	while total_time > t:
		total_time -= a[left]
		left += 1
	if right - left > max_total_book:
		max_total_book = right - left
		max_left = left
	if right < n:
		total_time += a[right]
		right += 1
	else:
		break
print(max_total_book)


(n, t) = map(int, input().split())
seq = list(map(int, input().split()))
head = 0
tail = 0
s = []
x = 0
count = 1
ans = 0
cursum = seq[0]
for i in range(n):
	x += seq[i]
	s.append(x)
while head != n:
	if head != 0:
		if tail == n:
			break
		cursum = s[tail] - s[head - 1]
	else:
		if tail == n:
			break
		cursum = s[tail]
	while cursum <= t:
		tail += 1
		count += 1
		if head != 0:
			if tail == n:
				break
			cursum = s[tail] - s[head - 1]
		else:
			if tail == n:
				break
			cursum = s[tail]
	head += 1
	count -= 1
	ans = max(ans, count)
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
sum = 0
s = 0
max1 = 0
i = 0
while i < n:
	if sum + a[i] > t:
		if sum != 0:
			sum -= a[s]
			s += 1
			if count > max1:
				max1 = count
			count -= 1
			i -= 1
	else:
		sum += a[i]
		count += 1
	i += 1
if count > max1:
	max1 = count
print(max1)


startIndex = 0
endIndex = 0
timeSum = 0
counter = 0
(n, t) = map(int, input().split())
timeList = input().split()
for i in range(n):
	timeSum += int(timeList[i])
	endIndex = i
	if timeSum > t:
		timeSum -= int(timeList[startIndex])
		startIndex += 1
	if counter < endIndex - startIndex + 1:
		counter = endIndex - startIndex + 1
print(counter)


(n, t) = map(int, input().split())
b = list(map(int, input().split()))
l = 0
r = 0
s = b[r]
mx = 0
while r < n - 1 or l < n:
	if s <= t and r < n - 1:
		r += 1
		s += b[r]
	elif r == n - 1 and s <= t:
		mx = max(mx, r - l + 1)
		break
	elif r < n - 1:
		mx = max(mx, r - l)
		s -= b[l]
		l += 1
	else:
		s -= b[l]
		l += 1
print(mx)


from sys import stdin

def high(x, y):
	if x >= y:
		return x
	else:
		return y

def tot():
	n = stdin.readline().strip().split()
	k = stdin.readline().strip().split()
	(a, t) = (0, 0)
	(b, c) = (1, 1)
	a = 0
	suma = 0
	b = 0
	for elem in range(int(n[0])):
		suma += int(k[elem])
		while suma > int(n[1]):
			suma -= int(k[b])
			b += 1
		a = high(a, elem - b + 1)
	print(a)
tot()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2
for _ in range(1):
	(n, t) = map(int, input().split())
	book = list(map(int, input().split()))
	book.insert(0, 0)
	ans = 0
	for i in range(1, n + 1):
		book[i] += book[i - 1]
	(l, r) = (1, 1)
	while True:
		r = max(r, l)
		if r <= n and l <= r:
			if book[r] - book[l - 1] <= t:
				ans = max(ans, r - l + 1)
				r += 1
			else:
				l += 1
		else:
			break
	print(ans)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
final = []
max = -10 ** 12
sum = 0
count = 0
j = 0
for i in range(n):
	sum += l[i]
	if sum > t:
		sum -= l[j]
		j += 1
print(n - j)


(n, t) = input().split()
t = int(t)
n = int(n)
s = list(map(int, input().split()))
j = 0
i = 0
ma = 0
co = s[0]
coe = 0
while True:
	if co > t:
		co -= s[i]
		i += 1
	else:
		coe += 1
		ma = max(ma, coe)
	j += 1
	if j >= n:
		break
	co += s[j]
print(ma)


import sys
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
sys.setrecursionlimit(10 ** 7)
mod = 1000000007

def max_len(a, t):
	(s, e, Sum) = (0, 0, 0)
	maxx = -1
	for i in a:
		Sum += i
		e += 1
		while Sum > t:
			Sum -= a[s]
			s += 1
		maxx = max(maxx, e - s)
	return maxx

def main():
	(n, t) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	print(max_len(a, t))
main()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
j = 0
s = 0
num = 0
while i < n:
	while j < n and s + a[j] <= t:
		s += a[j]
		j += 1
	num = max(num, j - i)
	s -= a[i]
	i += 1
print(num)


(n, t) = map(int, input().split(' '))
read_times = list(map(int, input().split(' ')))
max_books = -1
r = 0
cur_sum = read_times[0]
for i in range(len(read_times)):
	if i > 0:
		cur_sum -= read_times[i - 1]
	while r < n - 1 and cur_sum <= t:
		r += 1
		cur_sum += read_times[r]
	d = r - i if cur_sum > t else r - i + 1
	if d > max_books:
		max_books = d
print(max_books)


def solv(time_range, n, t):
	total = 0
	start = 0
	end = 0
	count = 0
	for end in range(n):
		total += time_range[end]
		count += 1
		if total > t:
			total -= time_range[start]
			count -= 1
			start += 1
	print(count)
(n, t) = [int(x) for x in input().split()[0:2]]
time_range = input()
time_range = [int(x) for x in time_range.split()]
solv(time_range, n, t)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()
wrt = sys.stdout.write
pr = lambda *args, end='\n': wrt(' '.join([str(x) for x in args]) + end)
enum = enumerate
inf = float('inf')
cdiv = lambda x, y: -(-x // y)

def DFS(gr, cost):
	n = len(gr)
	vis = [False for i in range(n)]
	fin = [False for i in range(n)]
	dfs = [None for i in range(n)]
	ans = 0

	def dfs(node):
		stack = [node]
		while stack:
			node = stack[-1]
			if not vis[node]:
				vis[node] = True
				for i in gr[node]:
					if not vis[i]:
						stack.append(i)
			else:
				stack.pop()
				ret = cost[node]
				for i in gr[node]:
					if not fin[i]:
						ret = min(ans, dfs[i])
				fin[node] = True
		dfs[node] = ret
		return dfs[node]
	for i in range(n):
		if not vis[i]:
			ans += dfs(i)
	return ans
_T_ = 1
for _t_ in range(_T_):
	(n, t) = inar()
	a = inar()
	pref = [0]
	for i in a:
		pref.append(pref[-1] + i)
	ans = 0
	for l in range(1, n + 1):
		low = l - 1
		high = n + 1
		while high > low:
			mid = (high + low) // 2
			if pref[mid] - pref[l - 1] <= t:
				ans = max(ans, mid - l + 1)
				low = mid + 1
			else:
				high = mid
	print(ans)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
(cnt, book, j) = (0, 0, 0)
for i in range(n):
	cnt += l[i]
	if cnt > t:
		cnt -= l[j]
		j += 1
print(len(l) - j)


(n, t) = map(int, input().split(' '))
c = [int(x) for x in input().split(' ')]
s = 0
i = 0
j = 0
k = 0
a = 0
while j < n:
	if s + c[j] > t:
		while s + c[j] > t and k > 0:
			s -= c[i]
			k -= 1
			i += 1
	s += c[j]
	k += 1
	j += 1
	a = max(a, k)
if min(c) > t:
	print(0)
else:
	print(a)


def solve(arr, n, time):
	(sum1, count) = (0, 0)
	j = -1
	for i in range(n):
		if sum1 + arr[i] <= time:
			sum1 += arr[i]
		else:
			sum1 += arr[i]
			while sum1 > time:
				j += 1
				sum1 -= arr[j]
		count = max(count, i - j)
	return count
(n, t) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
print(solve(arr, n, t))


(N, T) = map(int, input().split())
A = list(map(int, input().split()))
books = 0
j = 0
i = 0
mark = 0
check = 0
while j < N and i < N:
	if check + A[j] <= T:
		check += A[j]
		j += 1
		mark += 1
	else:
		books = max(mark, books)
		mark -= 1
		check -= A[i]
		i += 1
books = max(mark, books)
print(books)


line1 = input()
line2 = input()
line1 = line1.split(' ')
line2 = line2.split(' ')
n = int(line1[0])
t = int(line1[1])
bookCount = 0
sumReadingTime = 0
arbitraryStart = 0
i = 0
while i < n:
	sumReadingTime += int(line2[i])
	if sumReadingTime <= t:
		bookCount += 1
	else:
		sumReadingTime -= int(line2[arbitraryStart])
		arbitraryStart += 1
	i += 1
print(bookCount)


(n, t) = map(int, input().split())
lst = list((int(num) for num in input().split()))[:n]
count1 = count = 0
sum1 = 0
j = 0
for i in range(0, n):
	if sum1 + lst[i] <= t:
		sum1 += lst[i]
		count1 += 1
	elif sum1 + lst[i] > t:
		sum1 = sum1 - lst[j] + lst[i]
		j += 1
	if count1 > count:
		count = count1
print(count)


(n, t) = input().split()
n = int(n)
t = int(t)
a = [int(x) for x in input().split()]
dp = []
dp.append(0)
dp.append(a[0])
for i in range(1, n):
	dp.append(dp[i] + a[i])
i = 1
j = 1
lans = -1
rans = -1
while j < n + 1 and i < n + 1:
	if dp[j] - dp[i - 1] <= t:
		j += 1
	else:
		if j - i > rans - lans:
			rans = j
			lans = i
		i += 1
if j - i > rans - lans:
	rans = j
	lans = i
if lans == -1:
	print(0)
else:
	print(rans - lans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
summ = 0
j = 0
ans = 0
for i in range(n):
	summ += a[i]
	while summ > t:
		summ -= a[j]
		j += 1
	ans = max(ans, i - j + 1)
print(ans)


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
maxi = 0
ind = 0
ran = 0
back = 0
us = m
while ind < n:
	back = ind - ran
	while us - l[ind] < 0:
		if back == ind:
			break
		us += l[back]
		back += 1
		if ran > 0:
			ran -= 1
	if us - l[ind] >= 0:
		us -= l[ind]
		ran += 1
	ind += 1
	maxi = max(maxi, ran)
print(maxi)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
m_left = 0
m_right = 0
c = 0
c_left = 0
i = 0
while i < n:
	if c + a[i] <= t:
		c += a[i]
	elif c + a[i] - a[c_left] <= t:
		c += a[i] - a[c_left]
		c_left += 1
	else:
		c += a[i]
		while c > t:
			c -= a[c_left]
			c_left += 1
	if i - c_left > m_right - m_left:
		(m_left, m_right) = (c_left, i)
	i += 1
if t < min(a):
	print(0)
else:
	print(m_right - m_left + 1)


__author__ = 'runekri3'
(n, t) = list(map(int, input().split()))
times = list(map(int, input().split()))
max_books = 0
max_books_changed = 0
min_time = 0
for i in range(n):
	first_book_time = times[i]
	try:
		min_time += times[i + max_books]
	except IndexError:
		break
	if min_time <= t:
		max_books_changed = 1
		while 1:
			try:
				temp_min_time = min_time + times[i + max_books + max_books_changed]
			except IndexError:
				break
			if temp_min_time <= t:
				min_time = temp_min_time
				max_books_changed += 1
			else:
				min_time = temp_min_time
				break
		max_books += max_books_changed
		pass
	min_time -= first_book_time
print(max_books)


(n, t) = map(int, input().split())
max_answer = 0
a = list(map(int, input().split()))
answer = 0
reading = 0
for i in range(n):
	reading += a[i]
	if reading <= t:
		answer += 1
		if max_answer < answer:
			max_answer = answer
	else:
		reading -= a[i - answer]
print(max_answer)


(n, t) = map(int, input().split())
arrMinutes = list(map(int, input().split()))
amount = []
count = 0
sumMinute = 0
index = 0
for i in range(n):
	if sumMinute + arrMinutes[i] <= t:
		sumMinute = sumMinute + arrMinutes[i]
		count += 1
		index = i
	else:
		break
if count == n:
	print(count)
else:
	left = 0
	amount.append(count)
	for i in range(count, n):
		sumMinute = sumMinute + arrMinutes[i]
		for j in range(left, i + 1):
			if sumMinute > t:
				sumMinute = sumMinute - arrMinutes[left]
				left = left + 1
			else:
				break
		amount.append(i - left + 1)
	print(max(amount))


(n, t) = map(int, input().strip().split())
L = list(map(int, input().strip().split()))
k = 0
l = 0
cnt = 0
for i in range(n):
	while t < L[i]:
		t += L[l]
		l += 1
		cnt -= 1
	t -= L[i]
	cnt += 1
	k = max(k, cnt)
print(k)


(n_books, total_time) = [int(x) for x in input().split()]
estimated_times = [int(x) for x in input().split()]
max_len = 0
group = []
sum_time = 0
for t in estimated_times:
	group.append(t)
	sum_time += t
	if sum_time <= total_time:
		if len(group) > max_len:
			max_len = len(group)
	else:
		while sum_time > total_time:
			sum_time -= group[0]
			del group[0]
print(max_len)


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))[:n]
c = 0
l = 0
for i in range(n):
	l += a[i]
	if l > t:
		l -= a[c]
		c += 1
print(n - c)


(N, T) = map(int, input().split())
values = [int(n) for n in input().split()][0:N]
r = 0
l = 0
sum = 0
mx = 0
while r < N:
	sum += values[r]
	if sum <= T:
		mx = max(mx, r - l + 1)
	while sum > T:
		sum -= values[l]
		l += 1
	r += 1
print(mx)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
vmax = 0
j = 0
for i in range(n):
	if t < a[i]:
		t += a[j]
		j += 1
		count -= 1
	t -= a[i]
	count += 1
	vmax = max(vmax, count)
print(vmax)


(n, t) = map(int, input().split())
list = [int(i) for i in input().split()]
temp = []
sum = 0
count = 0
j = 0
step = 0
while j < n and sum + list[j] <= t:
	sum += list[j]
	count += 1
	j += 1
temp.append(count)
for i in range(1, n):
	sum -= list[i - 1]
	count -= 1
	while j < n and sum + list[j] <= t:
		sum += list[j]
		count += 1
		j += 1
	temp.append(count)
print(max(temp))


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	(n, t) = Mint()
	a = List()
	j = 0
	s = 0
	for i in range(n):
		s += a[i]
		if s > t:
			s -= a[j]
			j += 1
	print(n - j)
solution()


(books, time) = map(int, input().split())
lis = list(map(int, input().split()))
num = 0
x = 0
temp = 0
for x in range(len(lis)):
	temp += lis[x]
	if temp > time:
		temp -= lis[num]
		num += 1
print(x - num + 1)


(n, t) = map(int, input().split())
l = [*map(int, input().split())]
total = 0
j = 0
cnt = 0
ans = 0
for i in range(n):
	total += l[i]
	cnt += 1
	if total <= t:
		ans = max(ans, cnt)
	else:
		while total > t:
			total -= l[j]
			cnt -= 1
			ans = max(ans, cnt)
			j += 1
print(ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
t = 0
j = 0
for i in range(j, n):
	if t + l[i] > m:
		break
	else:
		t = t + l[i]
		j = j + 1
ma = j
if j != n:
	p = 0
	for i in range(j, n):
		t = t + l[i]
		if t > m:
			while t > m:
				t = t - l[p]
				p = p + 1
		if p > i:
			c = 0
		else:
			c = abs(p - i) + 1
		ma = max(ma, c)
print(ma)


import heapq as hp
import collections
import bisect
import math
import re

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def ml_unpack(n):
	return [int(input()) for i in range(n)]

def range_n():
	return range(int(input()))

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def getint():
	return int(input())

def main():
	(n, t) = unpack()
	a = l_unpack()
	window = 0
	ans = 0
	(lo, hi) = (0, -1)
	i = 0
	while i < n:
		window += a[i]
		if window > t:
			window -= a[i]
			break
		hi = i
		i += 1
		ans += 1
	while i < n:
		window += a[i] - a[lo]
		lo += 1
		i += 1
		while i < n:
			window += a[i]
			if window > t:
				window -= a[i]
				break
			hi = i
			i += 1
		ans = max(ans, hi - lo + 1)
	print(ans)
main()


(n, t) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
(x1, x2) = (0, 0)
b = 0
b_max = 0
while x2 < n:
	if a[x2] <= t:
		b += 1
		t -= a[x2]
		x2 += 1
	elif x1 == x2:
		x1 += 1
		x2 += 1
		b = 0
	else:
		b -= 1
		t += a[x1]
		x1 += 1
	if b > b_max:
		b_max = b
print(b_max)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
(j, i) = (0, 0)
c = 0
m = 0
while j < n:
	if t - l[j] >= 0:
		t -= l[j]
		c = j - i + 1
	else:
		t += l[i]
		c = j - i
		i += 1
		j -= 1
	m = max(m, c)
	j += 1
print(m)


(a, b) = map(int, input().split())
book = list(map(int, input().split()))
t = 0
start = 0
for i in range(a):
	t += book[i]
	if t > b:
		t -= book[start]
		start += 1
print(a - start)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
sum1 = 0
z = 0
j = 0
k = 0
for x in range(n):
	z += 1
	sum1 += a[x]
	while sum1 > t:
		sum1 -= a[j]
		j += 1
		z -= 1
		if z > k:
			k = z
	if z > k:
		k = z
print(k)


(no_of_books, total_free_time) = map(int, input().split())
book_time = list(map(int, input().split()))
books_read_count = res = 0
for book in range(no_of_books):
	res += book_time[book]
	if res > total_free_time:
		res -= book_time[books_read_count]
		books_read_count += 1
print(no_of_books - books_read_count)


def find(t, times):
	left = -1
	s = 0
	ans = 0
	for right in range(len(times)):
		if s + times[right] <= t:
			s += times[right]
		else:
			s += times[right]
			while s > t:
				left += 1
				s -= times[left]
		ans = max(ans, right - left)
	return ans

def main():
	(n, t) = map(int, input().split())
	times = list(map(int, input().split()))
	print(find(t, times))
main()


from sys import stdin, stdout

def solve(n, t, books):
	sam = 0
	cnt = 0
	time = 0
	count = 0
	i = 0
	while i < n:
		if time + books[i] > t:
			time -= books[cnt]
			cnt += 1
			i -= 1
			sam -= 1
		else:
			time += books[i]
			sam += 1
			count = max(sam, count)
		i += 1
	return count
(n, t) = list(map(int, stdin.readline().rstrip().split()))
books = list(map(int, stdin.readline().rstrip().split()))
stdout.write(str(solve(n, t, books)))


(n, t) = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
i = 0
time = 0
ret = 0
cnt = 0
while i < n:
	time += data[i]
	if time <= t:
		cnt += 1
	else:
		time -= data[i - cnt]
	i += 1
print(cnt)


(n, t) = map(int, input().split())
all_a = list(map(int, input().split()))
sums = []
(s, start) = (t, 0)
for (stop, element) in enumerate(all_a):
	s -= element
	while s < 0:
		s += all_a[start]
		start += 1
	sums.append(stop - start)
print(max(sums) + 1)


(n, t) = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
bc = 0
j = 0
tr = t
for i in range(n):
	while j < n and tr >= b[j]:
		tr -= b[j]
		j += 1
	bc = max(bc, j - i)
	tr += b[i]
print(bc)


(n, t) = map(int, input().split())
ara = [int(x) for x in input().split()]
s = 0
count = 0
ivy = 0
for i in range(0, n):
	while t < ara[i]:
		t += ara[s]
		s += 1
		count -= 1
	t -= ara[i]
	count += 1
	if count >= ivy:
		ivy = count
print(ivy)


vals = [int(x) for x in input().split()]
n = vals[0]
t = vals[1]
readTime = [int(x) for x in input().split()]
start = 0
current = 0
prevTime = 0
maxBooks = 0
while start < n and current < n:
	if prevTime + readTime[current] <= t:
		prevTime += readTime[current]
		current += 1
		if current == n:
			maxBooks = max(maxBooks, current - start)
	else:
		maxBooks = max(maxBooks, current - start)
		prevTime -= readTime[start]
		start += 1
print(maxBooks)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
left = 0
best_n = 0
current_sum = 0
for right in range(n):
	current_sum += a[right]
	while current_sum > t:
		current_sum -= a[left]
		left += 1
	best_n = max(best_n, right - left + 1)
print(best_n)


(n, t) = input().split()
(n, t) = (int(n), int(t))
l = list(map(int, input().split()))
sum = 0
j = 0
ans = 0
for i in range(n):
	if l[i] + sum <= t:
		sum = sum + l[i]
	else:
		sum = sum + l[i]
		while sum > t:
			sum = sum - l[j]
			j += 1
	ans = max(ans, i + 1 - j)
print(ans)


(N, T) = map(int, input().split())
L = list(map(int, input().split()))
left = 0
right = 0
nowcnt = 0
nowtime = 0
ans = 0
while right < N:
	if nowtime + L[right] <= T:
		nowtime += L[right]
		nowcnt = right - left + 1
		ans = max(ans, nowcnt)
		right += 1
	else:
		if left == right:
			right += 1
		else:
			nowtime -= L[left]
		left += 1
		nowcnt = right - left + 1
print(ans)


def main():
	(number_of_books, minutes) = [int(i) for i in input().split()]
	books = [int(i) for i in input().split()]
	max_number_of_books = 0
	count = 0
	j = 0
	for i in range(number_of_books):
		while minutes < books[i]:
			minutes += books[j]
			j += 1
			count -= 1
		minutes -= books[i]
		count += 1
		if count > max_number_of_books:
			max_number_of_books = count
	print(max_number_of_books)
main()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
a.append(t)
i = 0
j = 0
sum_time = 0
max_read_books = 0
while i < len(a):
	sum_time += a[i]
	if sum_time > t:
		if i - j > max_read_books:
			max_read_books = i - j
		while j < n and sum_time > t:
			sum_time -= a[j]
			j += 1
	i += 1
print(max_read_books)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
(num, j, s) = (0, 0, 0)
for i in range(n):
	s += arr[i]
	if s > t:
		s -= arr[j]
		j += 1
	num = max(num, i - j + 1)
print(num)


from sys import *
from math import *
from sys import stdin, stdout
from collections import *
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
(n, t) = get_int()
arr = int_arr()
length = 0
su = 0
mx = 0
lst = deque()
for i in range(n):
	su += arr[i]
	length += 1
	lst.append(arr[i])
	while su > t:
		su -= lst.popleft()
		length -= 1
	mx = max(mx, length)
print(mx)


(n, m) = map(int, input().split())
s = 0
c = 0
cnt = 0
a = list(map(int, input().split()))
for i in range(len(a)):
	s = s + a[i]
	if s <= m:
		cnt = cnt + 1
	else:
		s = s - a[c]
		c = c + 1
print(cnt)


(n, time) = input().split()
n = int(n)
time = int(time)
t = input().split()
z = 0
j = 0
maximum = 0
for i in range(n):
	t[i] = int(t[i])
	z += t[i]
	if z > time:
		z = z - t[j]
		j += 1
	if maximum < i - j + 1:
		maximum = i - j + 1
print(maximum)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = pointer = ans = 0
for i in range(n):
	s += a[i]
	while s > m:
		s -= a[pointer]
		pointer += 1
	ans = max(ans, i - pointer + 1)
print(ans)


r = lambda : map(int, input().split())
(n, t) = r()
a = list(r())
i = 0
s = 0
u = 0
while i < n:
	s += a[i]
	if s > t:
		s -= a[u]
		u += 1
	i += 1
print(n - u)


def main():
	(n, t) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	p = [a[0]]
	for i in range(1, n):
		p.append(p[i - 1] + a[i])
	i = 0
	j = 0
	m = 0
	while j < n:
		cur = p[j]
		if i > 0:
			cur -= p[i - 1]
		if cur <= t:
			m = max(m, j - i + 1)
		if cur < t:
			j += 1
		else:
			i += 1
	return m
print(main())


import bisect
(n, t) = map(int, input().split())
ls = list(map(int, input().split()))
nls = [0, ls[0]]
for i in range(1, n):
	nls.append(nls[-1] + ls[i])
ma = 0
for i in range(1, n + 1):
	st = nls[i - 1]
	ma = max(ma, bisect.bisect_right(nls, t + st) - i)
print(ma)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
k = 0
maxi = 0
s = [0] * n
sum = 0
for j in range(n - 1, -1, -1):
	sum += a[j]
	s[j] = sum
while i < n - maxi:
	sum = 0
	flag = False
	if t >= s[i]:
		if maxi < n - i:
			maxi = n - i
		break
	else:
		l = i + 1
		r = n
		tar = s[i] - t
		while l < r:
			mid = (l + r) // 2
			if s[mid] >= tar:
				l = mid + 1
			else:
				r = mid
		if maxi < l - (i + 1):
			maxi = l - (i + 1)
	i += 1
print(maxi)


fristIn = input().split()
n = int(fristIn[0])
t = int(fristIn[1])
numbers = [int(n) for n in input().split()]
acc = 0
init = 0
qtd = 0
for i in range(n):
	qtd = qtd + 1
	acc = acc + numbers[i]
	if acc > t:
		qtd = qtd - 1
		acc = acc - numbers[init]
		init = init + 1
print(qtd)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
output = 0
start = 0
for i in range(n):
	for j in range(start, n):
		t = t - a[j]
		if t < 0:
			start = j + 1
			t = t + a[i]
			break
		output = max(output, j - i + 1)
print(output)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
time = 0
count = 0
x = 0
for i in range(len(a)):
	time += a[i]
	count += 1
	if time > t:
		time -= a[x]
		x += 1
		count -= 1
print(count)


(n, t) = input().split()
n = int(n)
t = int(t)
a = list(map(int, input().split()))
z = 0
c = 0
d = 0
for i in range(n):
	c += a[i]
	while c > t:
		c -= a[d]
		d += 1
	z = max(z, i - d + 1)
print(z)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
mx = 0
sum = 0
c = 0
j = 0
for i in range(n):
	sum += a[i]
	c += 1
	if sum <= t:
		mx = max(c, mx)
	while sum >= t:
		sum -= a[j]
		j += 1
		c -= 1
print(mx)


line = input().split()
n = int(line[0])
t = int(line[1])
times = [int(x) for x in input().split()]
s = 0
left = 0
ans = 0
for right in range(n):
	s += times[right]
	while s > t:
		left += 1
		s -= times[left - 1]
	ans = max(ans, right - left + 1)
print(ans)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
(n, t) = rinput()
A = rlinput()
max = 0
for i in range(n):
	if i == 0:
		total = 0
		count = 0
		for j in range(i, n):
			if t - total < A[j]:
				break
			total += A[j]
			count += 1
	else:
		total = total - A[i - 1]
		count -= 1
		for j in range(end, n):
			if t - total < A[j]:
				break
			total += A[j]
			count += 1
	if count > max:
		max = count
	end = j
	if end == n - 1:
		print(max)
		break
else:
	print(max)


(n, m) = map(int, input().split())
lista = list(map(int, input().split()))
x = y = soma = resposta = 0
while x < n:
	while y < n and soma + lista[y] <= m:
		soma += lista[y]
		y += 1
	resposta = max(resposta, y - x)
	soma -= lista[x]
	x += 1
print(resposta)


(n, t) = map(int, input().split())
li = [int(x) for x in input().split()]
pref = [li[0]] + [0] * (n - 1)
for i in range(1, n):
	pref[i] = pref[i - 1] + li[i]
count = [0] * n
for i in range(n):
	if pref[i] == t:
		count[0] = i + 1
		note = i
		break
	elif pref[i] > t:
		if i == 0:
			note = 0
			count[0] = 0
			break
		else:
			note = i - 1
			count[0] = note - i + 1
			break
else:
	count[0] = n
	note = n - 1
for i in range(1, n):
	note = max(note, i)
	while pref[note] - pref[i] + li[i] < t:
		if note == n - 1:
			count[i] = n - i
			break
		note += 1
	else:
		if pref[note] - pref[i] + li[i] == t:
			count[i] = note - i + 1
		else:
			note -= 1
			count[i] = note - i + 1
print(max(count))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))

def Max_number_of_book_can_read(a, n, t):
	ans = 0
	i = index = 0
	count = 0
	while i < n:
		if t >= a[i]:
			t -= a[i]
			count += 1
			i += 1
		else:
			t += a[index]
			count -= 1
			i = index + count + 1
			index += 1
		if count >= ans:
			ans = count
	return ans
print(Max_number_of_book_can_read(a, n, t))


(n, t) = map(int, input().split())
line = list(map(int, input().split()))
res = list()
l = r = 0
ans = temp = 0
while r < n:
	temp += line[r]
	r += 1
	while temp > t:
		temp -= line[l]
		l += 1
	ans = max(ans, r - l)
print(ans)


def binirySearch(ps, l, r, t):
	while r - l > 1:
		m = l + (r - l) // 2
		diff = ps[m] - ps[i - 1]
		if diff <= t:
			l = m
		else:
			r = m
	return l
(n, t) = map(int, input().split())
a = [0] + [int(i) for i in input().split()]
cs = 0
pref_sums = []
for i in a:
	cs += i
	pref_sums.append(cs)
ans = 0
for i in range(1, n + 1):
	result = binirySearch(pref_sums, i - 1, n + 1, t)
	ans = max(ans, result - i + 1)
print(ans)


def sol(a, n, t):
	(i, j, ans, tans) = (0, 0, 0, 0)
	while j < n:
		if a[j] <= t:
			tans += 1
			t -= a[j]
			j += 1
		else:
			ans = max(ans, tans)
			while j < n and a[j] > t:
				if i != j:
					t += a[i]
					i += 1
					tans -= 1
				else:
					i += 1
					j += 1
	ans = max(ans, tans)
	return ans
(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
print(sol(a, n, t))


first_line = list(map(int, input().split()))
n = first_line[0]
t = first_line[1]
a = list(map(int, input().split()))

def main():
	sum = 0
	ans = 0
	(i, l) = (0, 0)
	while i < n:
		sum += a[i]
		while sum > t:
			sum -= a[l]
			l += 1
		ans = max(ans, i - l + 1)
		i += 1
	print(ans)
	return
main()


(n, t) = map(int, input().split())
count = 0
a = list(map(int, input().split()))[:n]
c = 0
d = 0
for i in range(len(a)):
	d += a[i]
	if d > t:
		d -= a[c]
		c += 1
print(n - c)


(n, t) = map(int, input().split())
f = list(map(int, input().split()))
sums = [0, f[0]]
max_book = 0
for i in range(1, n):
	sums.append(sums[i] + f[i])
for start in range(1, n + 1):
	for end in range(start + max_book, n + 1):
		k = sums[end] - sums[start - 1]
		if k > t:
			break
		else:
			max_book = end - start + 1
print(max_book)


(n, t) = input().split()
(n, t) = map(int, [n, t])
s = input()
A = []
for i in s.split():
	A.append(int(i))
Max = 0
time = 0
count = 0
x = 0
for j in range(0, n):
	time = time + A[j]
	count = count + 1
	if time > t:
		time = time - A[x]
		x = x + 1
		count = count - 1
	elif time == t:
		if j != n - 1:
			time = time - A[x]
			x = x + 1
			if count > Max:
				Max = count
			count = count - 1
	if count > Max:
		Max = count
print(Max)


def books(t, books):
	i = 0
	j = 0
	ds = [0]
	sum = 0
	while i < len(books) and j < len(books):
		if sum + books[j] > t:
			sum -= books[i]
			i += 1
		else:
			sum += books[j]
			j += 1
			ds.append(j - i)
	return max(ds)
(n, t) = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
print(books(t, b))


R = lambda : map(int, input().split())
(n, t) = R()
a = [*R()]
(maxReadBook, cnt, j) = (0, 0, 0)
for i in range(n):
	cnt += a[i]
	if cnt > t:
		cnt -= a[j]
		j += 1
print(n - j)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()
wrt = sys.stdout.write
pr = lambda *args, end='\n': wrt(' '.join([str(x) for x in args]) + end)
enum = enumerate
inf = float('inf')
cdiv = lambda x, y: -(-x // y)

def print(*args, end='\n'):
	for i in args:
		sys.stdout.write(str(i) + ' ')
	sys.stdout.write(end)
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def DFS(gr, cost):
	n = len(gr)
	vis = [False for i in range(n)]
	ans = 0

	@bootstrap
	def dfs(node):
		vis[node] = True
		ret = cost[node]
		for i in gr[node]:
			if not vis[i]:
				ret = min(ret, (yield dfs(i)))
		yield ret
	for i in range(n):
		if not vis[i]:
			ans += dfs(i)
	return ans
_T_ = 1
for _t_ in range(_T_):
	(n, t) = inar()
	a = inar()
	pref = [0]
	for i in a:
		pref.append(pref[-1] + i)
	ans = 0
	for l in range(1, n + 1):
		low = l - 1
		high = n + 1
		while high > low:
			mid = (high + low) // 2
			if pref[mid] - pref[l - 1] <= t:
				ans = max(ans, mid - l + 1)
				low = mid + 1
			else:
				high = mid
	print(ans)


from math import ceil

def isPossible(arr, l, t):
	currSum = sum(arr[:l])
	if currSum <= t:
		return True
	for i in range(l, len(arr)):
		currSum -= arr[i - l]
		currSum += arr[i]
		if currSum <= t:
			return True
	return False
(n, t) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
low = 0
high = n
curr = n
while low < high:
	if isPossible(arr, curr, t):
		if low == curr:
			break
		low = curr
	else:
		high = curr
	curr = (low + high) // 2
print(curr)


(books, free_time) = map(int, input().split())
time_arr = list(map(int, input().split()))
from_index = -1
(read_time, max_count) = (0, 0)
for i in range(books):
	if read_time + time_arr[i] <= free_time:
		read_time += time_arr[i]
	else:
		read_time += time_arr[i]
		while read_time > free_time:
			from_index += 1
			read_time -= time_arr[from_index]
	max_count = max(max_count, i - from_index)
print(max_count)


(n, t) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
j = 0
count = 0
books = 0
for i in range(n):
	while t < a[i]:
		t += a[j]
		j += 1
		count -= 1
	t -= a[i]
	count += 1
	books = max(books, count)
print(books)


import bisect
(n, t) = list(map(int, input().split()))
a = list(map(int, input().rstrip().split()))
b = [0]
sol = 0
for i in range(n):
	b.append(b[-1] + a[i])
b.pop(0)
for i in range(n):
	sol = max(sol, bisect.bisect_right(b, t) - i)
	t += a[i]
print(sol)


(n, t) = map(int, input().split())
li = list(map(int, input().split()))
ad = 0
un = 0
mx = 0
for i in range(n):
	ad += li[i]
	if ad > t:
		ad -= li[un]
		un += 1
	mx = max(mx, i - un + 1)
print(mx)


inp = list(map(int, input('').split(' ')))
(n, m) = (inp[0], inp[1])
nums = list(map(int, input('').split(' ')))
l = 0
total = 0
result = 0
for r in range(len(nums)):
	total += nums[r]
	if total > m:
		total -= nums[l]
		l += 1
	result = max(result, r - l + 1)
print(result)


import sys
from bisect import *

def Out(x):
	sys.stdout.write(str(x) + '\n')

def In():
	return sys.stdin.readline().strip()
Input = []

def inputGrab():
	for line in sys.stdin:
		Input.extend(map(int, line.strip().split()))

def main():
	inputGrab()
	n = Input[0]
	t = Input[1]
	v = Input[2:]
	Sum = [0 for i in range(n)]
	Sum[0] = v[0]
	for i in range(1, n):
		Sum[i] = Sum[i - 1] + v[i]
	ans = 0
	for (i, elem) in enumerate(Sum):
		pst = 0
		if i != 0:
			pst = Sum[i - 1]
		idx = bisect_right(Sum, elem + (t - v[i]))
		if idx:
			ans = max(ans, idx - i)
	print(ans)
main()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 0
total_time = 0
ans = 0
while r < n:
	while r < n and total_time + a[r] <= t:
		total_time += a[r]
		r += 1
	if r - l > ans:
		ans = r - l
	if r == n:
		break
	while l < n and total_time + a[r] > t:
		total_time -= a[l]
		l += 1
print(ans)


inputs = [int(x) for x in input().split()]
mins = inputs[1]
book_times = [int(x) for x in input().split()]
current_max = -1
current_time = 0
start_idx = 0
end_idx = -1
for i in range(len(book_times)):
	t = book_times[i]
	if t + current_time > mins:
		current_max = end_idx - start_idx if end_idx - start_idx > current_max else current_max
		while start_idx <= end_idx and t + current_time > mins:
			current_time -= book_times[start_idx]
			start_idx += 1
	if t + current_time <= mins:
		current_time += t
	else:
		current_time = 0
		start_idx = i + 1
	end_idx = i
current_max = end_idx - start_idx if end_idx - start_idx > current_max else current_max
print(current_max + 1)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]

def prefixsums(arr):
	from itertools import accumulate
	pref = [0] + list(accumulate(arr))
	return lambda l, r: pref[r] - pref[l - 1]
get = prefixsums(a)
r = 1
ans = 0
for l in range(1, n + 1):
	while r <= n and get(l, r) <= t:
		r += 1
	ans = max(ans, r - l)
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 0
c = 0
b = 0
ok = 1
while ok:
	while b <= t and r < n:
		b += a[r]
		r += 1
	if b > t:
		r -= 1
		b -= a[r]
		if c < r - l:
			c = r - l
		if r > l:
			b -= a[l]
		else:
			r += 1
	else:
		if c < r - l:
			c = r - l
		break
	l += 1
print(c)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
import math

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	(n, t) = ain()
	l = ain()
	i = 0
	j = 0
	suma = 0
	ans = 0
	while j < n:
		suma += l[j]
		if suma <= t:
			ans = max(ans, j - i + 1)
		else:
			while suma > t:
				suma -= l[i]
				i += 1
			ans = max(ans, j - i + 1)
		j += 1
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(l, r) = (0, 0)
sm = 0
mxl = 0
while r < len(a):
	if sm + a[r] <= t:
		sm += a[r]
		r += 1
	elif sm - a[l] >= 0:
		sm -= a[l]
		l += 1
	else:
		l += 1
		r += 1
		continue
	if l > r:
		r += 1
		continue
	mxl = max(mxl, r - l)
print(mxl)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	(n, k) = vars()
	arr = array()
	suf = []
	s = sum(arr)
	for i in range(n):
		suf.append(s)
		s -= arr[i]
	b = 0
	for i in range(n):
		l = i
		r = n - 1
		s = suf[i]
		books = 0
		while l <= r:
			m = (l + r) // 2
			new_s = s - suf[m] + arr[m]
			if new_s <= k:
				books = m - i + 1
				l = m + 1
			else:
				r = m - 1
		if books > b:
			b = books
	print(b)
t = 1
for _ in range(t):
	main()


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
i = n - 1
s = 0
while i >= 0 and s <= t:
	s += a[i]
	i -= 1
if i >= 0:
	i += 1
	s -= a[i]
	j = n - 2
	max_res = n - 1 - i
	while j >= 0 and i >= 0:
		s -= a[j + 1]
		while i >= 0 and s <= t:
			s += a[i]
			i -= 1
		res = j - i - 1
		if i < 0 and s <= t:
			res += 1
		if res > max_res:
			max_res = res
		j -= 1
		if i >= 0:
			i += 1
			s -= a[i]
	print(max_res)
else:
	print(n if s <= t else n - 1)


(numBooks, time) = map(int, input().split())
bookLengths = list(map(int, input().split()))
maximum = 0
firstIndex = 0
currSum = 0
currBooks = 0
for x in range(numBooks):
	if bookLengths[x] > time:
		currSum = 0
		currBooks = 0
		firstIndex = x + 1
		continue
	while currSum + bookLengths[x] > time:
		currSum -= bookLengths[firstIndex]
		firstIndex += 1
		currBooks -= 1
	currBooks += 1
	currSum += bookLengths[x]
	maximum = max(maximum, currBooks)
print(maximum)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
(start, end, _sum) = (0, -1, 0)
result = 0
while start < len(a):
	if _sum + a[start] <= t:
		_sum += a[start]
		start += 1
	elif _sum > 0:
		end += 1
		_sum -= a[end]
	else:
		end += 1
		start += 1
	result = max(result, start - end - 1)
print(result)


(n, t) = map(int, input().split())
mat = list(map(int, input().split()))
cnt = 0
tail = 0
res = 0
for i in range(n):
	cnt += mat[i]
	while cnt > t:
		cnt -= mat[tail]
		tail += 1
	if res < i - tail + 1:
		res = i - tail + 1
print(res)


def books(n, t, l):
	sum = 0
	a = 0
	ans = 0
	for i in range(n):
		sum += l[i]
		while sum > t:
			sum -= l[a]
			a += 1
		ans = max(ans, i - a + 1)
	return ans
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
print(books(n, t, l))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i0 = 0
i1 = 0
max_n = 0
s = 0
while i1 <= n:
	if s <= t:
		max_n = max(max_n, i1 - i0)
		if i1 == n:
			break
		s += a[i1]
		i1 += 1
	else:
		s -= a[i0]
		i0 += 1
print(max_n)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(l, r, ans) = (0, -1, 0)
temp = 0
while r < n - 1:
	r += 1
	temp += a[r]
	while temp > t:
		temp -= a[l]
		l += 1
	ans = max(ans, r - l + 1)
print(ans)


(n, t) = map(int, input().split())
c = list(map(int, input().split()))
for i in range(1, n):
	c[i] += c[i - 1]
(x, y) = (-1, 0)
m = 0
while y < n:
	if x == -1:
		if c[y] <= t:
			m = max(m, y + 1)
			y += 1
		else:
			x += 1
	elif c[y] - c[x] <= t:
		m = max(m, y - x)
		y += 1
	else:
		x += 1
print(m)


def binary_search(arr, left, right, value):
	while left <= right:
		mid = (left + right) // 2
		if value < arr[mid]:
			right = mid - 1
		elif value > arr[mid]:
			left = mid + 1
		else:
			return mid + 1
	return right + 1
(n, t) = map(int, input().split())
a = tuple(map(int, input().split()))
b = [a[0]] * n
for i in range(1, n):
	b[i] = b[i - 1] + a[i]
m = 0
for i in range(0, n):
	m = max(m, binary_search(b, i, n - 1, t) - i)
	t += a[i]
print(m)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
(l, r, s, k, res) = (0, 0, 0, 0, 0)
for r in range(n):
	s += a[r]
	while s > m:
		s -= a[l]
		l += 1
	res = max(res, r - l + 1)
print(res)


(n, t) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
l = 0
r = 0
max_count = 0
count = 0
time = 0
while l < n and r < n:
	while time <= t and r < n:
		time = time + a[r]
		if time <= t:
			count += 1
			r += 1
	max_count = max(count, max_count)
	count -= 1
	time -= a[l]
	if r < n:
		time -= a[r]
	l += 1
print(max_count)


(sosach, sophut) = map(int, input().split())
sach = list(map(int, input().split()))
(cnt, book, j) = (0, 0, 0)
for i in range(sosach):
	cnt += sach[i]
	if cnt > sophut:
		cnt -= sach[j]
		j += 1
print(len(sach) - j)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
	print(int(a[0] <= t))
else:
	(l, r) = (0, 0)
	res = 0
	s = a[0]
	while l != n - 1:
		if s < t and r != n - 1:
			r += 1
			s += a[r]
		else:
			l += 1
			s -= a[l - 1]
		if s <= t and r - l + 1 > res:
			res = r - l + 1
	print(res)


(num_books, total_time) = map(int, input().split())
books = list(map(int, input().split()))
left = 0
right = 0
max_num_books = 0
max_reading_time = 0
curr_num_books = 0
curr_reading_time = 0
while left < num_books and right < num_books:
	if left == right and books[right] > total_time:
		left += 1
		right += 1
	elif curr_reading_time + books[right] > total_time:
		curr_reading_time -= books[left]
		curr_num_books -= 1
		left += 1
	else:
		curr_reading_time += books[right]
		curr_num_books += 1
		if curr_num_books > max_num_books:
			max_reading_time = curr_reading_time
			max_num_books = curr_num_books
		right += 1
print(max_num_books)


(N, M) = map(int, input().split())
A = [0] + [int(i) for i in input().split()]
for i in range(1, len(A) - 1):
	A[i + 1] += A[i]
p1 = 0
p2 = 1
best = 0
while p2 < len(A):
	s = A[p2] - A[p1]
	if s <= M:
		best = max(best, p2 - p1)
		p2 += 1
	else:
		p1 += 1
print(best)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))[:n]
(res, time, count, j) = (0, 0, 0, 0)
for i in range(n):
	time += a[i]
	count += 1
	while time > t:
		time -= a[j]
		j += 1
		count -= 1
	if res < count:
		res = count
print(res)


def main():
	(n, t) = map(int, input().split())
	books = [int(number) for number in input().split()]
	maximum = 0
	for i in range(n):
		pointer1 = i
		if pointer1 > 0:
			time = time - books[pointer1 - 1]
		else:
			(pointer2, time) = (0, 0)
		while pointer2 < n and time + books[pointer2] <= t:
			time += books[pointer2]
			pointer2 += 1
		if pointer2 - pointer1 > maximum:
			maximum = pointer2 - pointer1
	print(maximum)
main()


(n, t) = list(map(int, input().split()))
book_times = list(map(int, input().split()))
sums = list(book_times)
for i in range(1, n):
	sums[i] += sums[i - 1]
sums = [0] + sums
n += 1
(left, right) = (1, 1)
max_books_num = 0

def move_while_can(left, right, t):
	for i in range(right, n):
		if sums[i] - sums[left - 1] > t:
			return i - 1
	return n - 1
last_right = left
while True:
	if left == n:
		break
	right = move_while_can(left, max(left, right), t)
	max_books_num = max(max_books_num, right - left + 1)
	left += 1
print(max_books_num)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
sumA = 0
c = 0
i = 0
j = 0
sumA = 0
ans = []
c = 0
while i < n:
	check = 1
	for k in range(j, n):
		sumA += a[k]
		if sumA > t:
			check = 0
			ans.append(c)
			goback = k
			sumA -= a[i]
			while sumA > t:
				sumA -= a[goback]
				goback -= 1
				c -= 1
			j = goback + 1
			break
		else:
			c += 1
	if check:
		ans.append(c)
		break
	i += 1
print(max(ans))


(n, t) = [int(s) for s in input().rstrip().split(' ')]
b = [int(s) for s in input().rstrip().split(' ')]
i = 0
j = 0
ans = 0
s = 0
while j < n:
	if s + b[j] <= t:
		s += b[j]
		ans = max(ans, j - i + 1)
		j += 1
	elif i == j:
		j += 1
		i += 1
	else:
		s -= b[i]
		i += 1
print(ans)


(n, t) = map(int, input().split())
books = list(map(int, input().split()))
read = [0]
c = 0
j = 0
summ = 0
i = 0
while i != n and j != n:
	if summ + books[j] <= t:
		c += 1
		summ += books[j]
		j += 1
	else:
		read.append(c)
		summ -= books[i]
		i += 1
		c -= 1
read.append(c)
print(max(read))


(x, y) = map(int, input().split())
s = [0] + list(map(int, input().split()))
for n in range(1, x + 1):
	s[n] += s[n - 1]
if x == 1:
	if s[1] <= y:
		print(1)
	else:
		print(0)
	exit(0)
l = 1
r = 1
res = 0
while r <= x and l <= r:
	sm = s[r] - s[l - 1]
	if sm <= y:
		res = max(res, r - l + 1)
		r += 1
	else:
		l += 1
		r += 1
print(res)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(p, k, q) = (0, 0, 0)
for i in a:
	q += i
	if q > t:
		q -= a[k]
		k += 1
print(n - k)


s = input().split()
n = int(s[0])
t = int(s[1])
s = input().split()
for i in range(len(s)):
	s[i] = int(s[i])
l = 0
r = 0
v = s[0]
res = 0
while r < len(s):
	if v <= t:
		res = max([res, r - l + 1])
		if r == len(s) - 1:
			break
		else:
			r += 1
			v += s[r]
	elif v > t:
		v -= s[l]
		l += 1
print(res)


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
cnt = 0
i0 = 0
t0 = 0
for i in range(n):
	cnt += 1
	t0 += a[i]
	if t0 > t:
		cnt -= 1
		t0 -= a[i0]
		i0 += 1
print(cnt)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(i_min, i_max) = (0, 0)
(N, T) = (0, 0)
while (i_min < n) & (i_max < n):
	while T <= t - a[i_max]:
		T += a[i_max]
		i_max += 1
		if i_max >= n:
			break
	if N < i_max - i_min:
		N = i_max - i_min
	T -= a[i_min]
	i_min += 1
print(N)


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
start = 0
max1 = 0
sum = a[0]
for i in range(1, len(a) + 1):
	if sum <= t:
		max1 = max(max1, i - start)
	while i < len(a) and sum + a[i] > t and (start < i):
		sum -= a[start]
		start += 1
	if i < len(a):
		sum += a[i]
print(max1)


(m, n) = map(int, input().split())
l = list(map(int, input().split()))
(k, s, j, i) = (0, 0, 0, 0)
while i < m:
	left = l[j]
	s = s + l[i]
	if s > n:
		s = s - left
		j = j + 1
	else:
		k = k + 1
	i = i + 1
print(k)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
sum = 0
start = 0
ans = 0
for i in range(len(l)):
	sum += l[i]
	while sum > t:
		sum -= l[start]
		start += 1
	ans = max(ans, i - start + 1)
print(ans)


(n, t) = map(int, input().split())
books = list(map(int, input().split()))
if sum(books) <= t:
	print(n)
	exit()
sum = 0
j = 0
while sum + books[j] <= t:
	sum += books[j]
	j += 1
counts = [j]
i = 0
j -= 1
while j + 1 < n:
	i += 1
	sum -= books[i - 1]
	while sum + books[j + 1] <= t:
		sum += books[j + 1]
		j += 1
		if j + 1 >= n:
			break
	counts.append(j + 1 - i)
print(max(counts))


l1 = input()
ant = l1.split()
n = int(ant[0])
t = int(ant[1])
l2 = input()
aa = l2.split()
a = []
for i in range(0, n):
	ai = int(aa[i])
	a.append(ai)
start = 0
max = 0
sum = 0
for i in range(0, n):
	sum += a[i]
	if sum <= t:
		max += 1
	else:
		sum = sum - a[start]
		start += 1
print(max)


(n, t) = [int(i) for i in input().split()]
books = list(map(int, input().strip().split(' ')))
(ia, ib, m) = (0, 0, 0)
s = 0
while ib < n:
	i = ib
	while i <= ib:
		if i > n - 1:
			break
		s += books[i]
		if s <= t:
			if abs(ib - ia) + 1 > m:
				m = abs(ib - ia) + 1
			ib += 1
		i += 1
	s -= books[ia]
	ia += 1
	ib += 1
print(m)


(n, t) = map(int, input().split())
booklist = list(map(int, input().split()))
pfs = []
pfs.append(0)
for i in range(n):
	pfs.append(pfs[i] + booklist[i])

def isPossible(nbooks):
	ttimes = [pfs[i + nbooks] - pfs[i] for i in range(n - nbooks + 1)]
	for tt in ttimes:
		if tt <= t:
			return True
	return False
lo = 0
hi = n
while lo < hi:
	mid = lo + (hi - lo + 1) // 2
	if isPossible(mid):
		lo = mid
	else:
		hi = mid - 1
print(lo)


def solve(arr, m, n):
	count = 0
	start = 0
	summ = 0
	for i in range(n):
		count += 1
		summ += arr[i]
		if summ > m:
			summ -= arr[start]
			start += 1
			count -= 1
	return count
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
print(solve(arr, m, n))


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
d = 0
f = 1
s = A[0]
r = 0 + (s <= t)
while f < n:
	while s <= t and f < n:
		s += A[f]
		f += 1
	r = max(r, f - d - (s > t))
	if f == n:
		break
	while s > t:
		s -= A[d]
		d += 1
print(r)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
time = t
start = 0
count = 0
max_count = 0
p_sum = 0
for end in range(len(arr)):
	if p_sum + arr[end] <= time:
		count += 1
		p_sum += arr[end]
	else:
		p_sum = p_sum - arr[start] + arr[end]
		start += 1
	if count > max_count:
		max_count = count
print(max_count)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
j = 0
c = t
z = []
m = 0
while j < n:
	if a[j] <= t:
		t -= a[j]
		j += 1
		m += 1
	else:
		z.append(m)
		m -= 1
		t += a[i]
		i += 1
z.append(m)
print(max(z))


(n, t) = [int(i) for i in input().split(' ')]
time = [int(i) for i in input().split(' ')]
_sum = 0
cnt = 0
maxcnt = 0
for i in range(n):
	if _sum + time[i] <= t:
		_sum += time[i]
		cnt += 1
	elif _sum != 0:
		_sum = _sum - time[i - cnt] + time[i]
	maxcnt = max(cnt, maxcnt)
print(maxcnt)


(books, time) = map(int, input().split())
numbers = [int(i) for i in input().split()]
i = j = sub = 0
ans = 0
for i in range(books):
	sub += numbers[i]
	if sub > time:
		sub -= numbers[j]
		j += 1
	ans = max(ans, i - j + 1)
print(ans)


(n, m) = [x for x in map(int, input().strip().split(' '))]
mins = list(map(int, input().strip().split(' ')))
books_track = 0
time = 0
left = 0
right = 0
while right < n:
	time += mins[right]
	while time > m:
		time -= mins[left]
		left += 1
	books_track = max(books_track, right - left + 1)
	right += 1
print(books_track)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
longest = curr = s = i = 0
while i < n:
	if s > t:
		longest = max(curr - 1, longest)
		s -= arr[i - curr]
		curr -= 1
	else:
		s += arr[i]
		curr += 1
		i += 1
while s > t:
	longest = max(curr - 1, longest)
	s -= arr[i - curr]
	curr -= 1
longest = max(curr, longest)
print(longest)


def test(n, t):
	left = 0
	right = 0
	sum = 0
	count = 0
	tracking = [0]
	while left < len(t) or right < len(t):
		if left > 0:
			sum -= t[left - 1]
		left += 1
		while right < len(t):
			sum += t[right]
			right += 1
			if sum <= n[1]:
				count += 1
			else:
				tracking.append(count)
				break
			if right == len(t):
				tracking.append(count)
				break
	return max(tracking)
n = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
print(test(n, t))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def can(m, s):
	return 0 <= s <= 9 * m
(n, t) = map(int, input().split())
a = list(invr())
(l, r) = (0, 0)
time_left = t
m = 0
while l < n:
	if l > r:
		r = l
		time_left = t
	elif r < n and time_left >= a[r]:
		time_left -= a[r]
		r += 1
	else:
		m = max(m, r - l)
		time_left += a[l]
		l += 1
print(m)


(n, t) = list(map(lambda x: int(x), input().split()))
a = list(map(lambda x: int(x), input().split()))
maximum = 0
i = 0
j = 1
s = a[i]
maximum = 0
if len(a) == 1 and a[0] <= t:
	print(1)
else:
	while i < len(a) and j < len(a):
		if s + a[j] <= t:
			s = s + a[j]
			j += 1
			if j - i > maximum:
				maximum = j - i
		else:
			s = s - a[i]
			i += 1
	print(maximum)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(st, en) = (n - 1, n - 1)
wsum = 0
ans = 0
while st >= 0:
	wsum += a[st]
	st -= 1
	while en > st and wsum > t:
		wsum -= a[en]
		en -= 1
	ans = max(ans, en - st)
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = r = l = m = 0
for i in range(n):
	while r < n:
		if s + a[r] <= t:
			s += a[r]
			r += 1
		else:
			break
		l += 1
	if l > m:
		m = l
	if i != r:
		s -= a[i]
		l -= 1
	else:
		r += 1
print(m)


import sys
input = sys.stdin.readline
(x, y) = map(int, input().split())
(*li,) = map(int, input().split())
li2 = [0] * x
li2[-1] = 1 if li[-1] <= y else 0
sum1 = li[-1]
ans = li2[-1]
j = x - 1
for i in range(x - 2, -1, -1):
	if li[i] > y:
		li2[i] = 0
		sum1 = 0
		j = i - 1
		continue
	sum1 += li[i]
	if sum1 <= y:
		li2[i] = li2[i + 1] + 1
	else:
		cnt = li2[i + 1] + 1
		while sum1 > y:
			sum1 -= li[j]
			j -= 1
			cnt -= 1
		li2[i] = cnt
	ans = max(ans, li2[i])
print(ans)


def read_input():
	(n, t) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	return (n, t, a)

def read_them(n, t, a):
	ts = [0] * len(a)
	cs = [0] * len(a)
	start_pos = 0
	time_remain = t
	while start_pos < len(a):
		i = cs[max(start_pos - 1, 0)] + max(start_pos - 1, 0)
		while i < len(a) and time_remain >= a[i]:
			time_remain -= a[i]
			i += 1
		ts[start_pos] = time_remain
		cs[start_pos] = i - start_pos
		time_remain += a[start_pos]
		start_pos += 1
	return max(cs)

def main():
	(n, t, a) = read_input()
	count = read_them(n, t, a)
	print(count)
main()


(n, mx) = map(lambda x: int(x), input().split())
a = [int(i) for i in input().split()]
i = 0
j = 0
running_total = 0
ans = 0
while j < len(a):
	running_total += a[j]
	while running_total > mx and i <= j:
		running_total -= a[i]
		i += 1
	ans = max(j - i + 1, ans)
	j += 1
print(ans)


def canBeRead(n, totalTime, times):
	total = totalTime
	tot1 = 0
	tot2 = 0
	for i in times[:n]:
		tot1 += i
	if tot1 <= totalTime:
		return True
	else:
		for j in range(n, len(times)):
			tot1 -= times[j - n]
			tot1 += times[j]
			if tot1 <= totalTime:
				return True
	return False

def BS(data, n, t):
	l = 0
	r = n
	ans = 0
	while l <= r:
		m = (l + r) // 2
		if canBeRead(m, t, data):
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans
(n, t) = map(int, input().split(' '))
data = list(map(int, input().split(' ')))
d = BS(data, n, t)
print(d)


(n, t) = map(int, input().split())
x = [int(x) for x in input().split()]
m = 0
j = 0
c = 0
for i in range(n):
	m += x[i]
	c += 1
	if m > t:
		m -= x[j]
		j += 1
		c -= 1
print(c)


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
count = 0
left = 0
s = 0
for i in range(0, n):
	s += a[i]
	while s > t:
		s -= a[left]
		left += 1
	count = max(count, i - left + 1)
print(count)


def inp():
	return map(int, input().split())
(n, t) = inp()
a = list(inp())
l = time = maxbooks = 0
for r in range(n):
	time += a[r]
	while time > t:
		time -= a[l]
		l += 1
	maxbooks = max(maxbooks, r - l + 1)
print(maxbooks)


def check(x, A):
	n = len(A)
	sum = 0
	for i in range(x):
		sum += A[i]
	if sum <= t:
		return True
	for i in range(x, n):
		sum -= A[i - x]
		sum += A[i]
		if sum <= t:
			return True
	return False
(n, t) = map(int, input().split())
A = list(map(int, input().split()))
l = 0
h = n
ans = 0
while l < h:
	mid = (l + h + 1) // 2
	if check(mid, A):
		l = mid
		ans = mid
	else:
		h = mid - 1
print(ans)


(books, full) = [int(x) for x in input().split()]
time_needed = [int(x) for x in input().split()]
(idx, done) = (0, 0)
for i in range(books):
	done += time_needed[i]
	if done > full:
		done -= time_needed[idx]
		idx += 1
print(books - idx)


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
(n, t) = [int(n1) for n1 in input().split()]
a = [int(n1) for n1 in input().split()]
b = [0] * n
j = 0
spent = 0
t1 = t
for i in range(len(b)):
	while t1 > 0 and j < n:
		if t1 >= a[j]:
			b[i] = b[i] + 1
			t1 = t1 - a[j]
			j = j + 1
		else:
			break
	if a[i] < t:
		t1 = t1 + a[i]
	else:
		t1 = t
		j = i + 1
	if i != n - 1:
		if b[i] > 0:
			b[i + 1] = b[i] - 1
print(max(b))


(n, t) = map(int, input().split())
m = [int(i) for i in input().split()]
best = 0
length = 0
su = 0
start = 0
for i in range(n):
	su += m[i]
	length += 1
	while su > t:
		su -= m[start]
		start += 1
		length -= 1
	best = max(best, length)
print(best)


import sys
(n, k) = list(map(int, input().split()))
timeList = list(map(int, input().split()))
l = 0
r = 0
ans = 0
count = 0
timeSpent = 0
for i in range(n):
	while r < n and k >= timeList[r] + timeSpent:
		timeSpent += timeList[r]
		count += 1
		r += 1
	ans = max(count, ans)
	timeSpent -= timeList[i]
	count -= 1
print(ans)


is_debug = False
(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
l = len(a)
s = 0
i = 0
for j in range(l):
	s += a[j]
	if s > t:
		s -= a[i]
		i += 1
print(f'{l - i}')


(n, t) = map(int, input().split())
ls = list(map(int, input().split()))
mn = -1
s = 0
i = j = 0
while s + ls[i] <= t:
	s = s + ls[i]
	i = i + 1
	if i == n:
		break
if i > mn:
	mn = i
while i < n:
	if s + ls[i] > t:
		s = s - ls[j]
		if i - j > mn:
			mn = i - j
		j = j + 1
	else:
		s = s + ls[i]
		i = i + 1
	if i == n:
		if i - j > mn:
			mn = i - j
print(mn)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
j = -1
s = 0
ans = 0
for i in range(n):
	if s + l[i] <= m:
		s += l[i]
	else:
		s += l[i]
		while s > m:
			j += 1
			s -= l[j]
	ans = max(ans, i - j)
print(ans)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
(start, res) = (0, [])
for (stop, a) in enumerate(l):
	t -= a
	while t < 0:
		t += l[start]
		start += 1
	res.append(stop - start)
print(max(res) + 1)


INPUT = lambda : list(map(int, input().split()))
(n, t) = INPUT()
a = INPUT()
sumTime = 0
left = 0
result = 0
for right in range(n):
	sumTime += a[right]
	while sumTime > t:
		sumTime -= a[left]
		left += 1
	result = max(result, right - left + 1)
print(result)


(n, t) = map(int, input().split())
times = list(map(int, input().split())) + [0]
for i in range(1, n):
	times[i] += times[i - 1]
l = 0
r = n + 1
while l + 1 < r:
	label = False
	m = (r + l) // 2
	for i in range(m - 1, n):
		if times[i] - times[i - m] <= t:
			label = True
			break
	if label:
		l = m
	else:
		r = m
print(l)


(n, t) = map(int, input().split())
s = input()
a = s.split()
summ = 0
k = 0
l = 0
maxim = 0
for i in range(len(a)):
	summ = summ + int(a[i])
	k += 1
	l += 1
	if summ > t:
		while summ > t:
			summ = summ - int(a[i + 1 - k])
			k -= 1
			l -= 1
	if l > maxim:
		maxim = l
print(maxim)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
j = 0
book = 0
sum = 0
u = 0
for i in range(n):
	sum += arr[i]
	book += 1
	if sum > m:
		sum -= arr[j]
		book -= 1
		u = max(book, u)
		j += 1
print(max(book, u))


(n, t) = str(input()).split()
n = int(n)
t = int(t)
m = 0
books = 0
books_list = list()
a = list(map(int, input().split(' ')))
for book in a:
	if m + book <= t:
		m += book
		books += 1
	else:
		break
books_list.append((books, m))
books = 0
counter = 0
for i in range(1, len(a)):
	books_m = books_list[i - 1][1] - a[i - 1]
	books = books_list[i - 1][0] - 1
	if i - 1 + books_list[i - 1][0] + counter < len(a):
		while books_m + a[i - 1 + books_list[i - 1][0] + counter] <= t:
			books_m += a[i - 1 + books_list[i - 1][0] + counter]
			counter += 1
			books += 1
			if i - 1 + books_list[i - 1][0] + counter >= len(a):
				break
	books_list.append((books, books_m))
	counter = 0
books_list.sort()
print(books_list[-1][0])


from collections import defaultdict
(n, t) = [int(i) for i in input().split(' ')]
numbers = [int(i) for i in input().split(' ')]
j = 0
hours = 0
maximum_subarray = 0
for i in range(n):
	hours += numbers[i]
	while j < i and hours > t:
		hours -= numbers[j]
		j += 1
	if hours <= t:
		maximum_subarray = max(maximum_subarray, i - j + 1)
print(maximum_subarray)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
j = 0
ans = 0
cur = 0
for i in range(n):
	if i > 0:
		cur -= a[i - 1]
	while j < n and cur + a[j] <= t:
		cur += a[j]
		j += 1
	if j - i > ans:
		ans = j - i
	if j == n:
		break
print(ans)


(n, t) = [int(x) for x in input().split()]
minutes = [int(x) for x in input().split()]
s = 0
result = 0
left = 0
right = 0
while left < n:
	while right < n and s + minutes[right] <= t:
		s += minutes[right]
		right += 1
	result = max(result, right - left)
	s -= minutes[left]
	left += 1
print('%d' % result)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = 0
max = 0
i = 0
j = 0
cnt = 0
for i in range(0, n):
	while m < a[i]:
		m += a[j]
		j += 1
		cnt -= 1
	m = m - a[i]
	cnt += 1
	if cnt > max:
		max = cnt
print(max)


def mi():
	return map(int, input().split())
(n, t) = mi()
a = list(mi())
res = 0
time = 0
count = 0
(i, j) = (0, 0)
while i < len(a) and j < len(a):
	if time + a[j] <= t:
		time += a[j]
		j += 1
		count += 1
		res = max(count, res)
	else:
		time -= a[i]
		count -= 1
		i += 1
print(res)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
(left, right) = (0, 0)
summ = 0
ans = 0
for i in range(n):
	summ += l[i]
	while summ > t:
		summ -= l[left]
		left += 1
	ans = max(ans, i - left + 1)
print(ans)


(n, t) = map(int, input().split())
ss = [int(i) for i in input().split()]
(s, j) = (0, 0)
for i in ss:
	s += i
	if s > t:
		s -= ss[j]
		j += 1
print(n - j)


l1 = [int(x) for x in input().split()]
n = l1[0]
t = l1[1]
l2 = [int(x) for x in input().split()]
l3 = []
s = 0
starting_index = 0
i = 0
while i < n and starting_index < n:
	if t >= l2[i]:
		t -= l2[i]
		s += 1
		i += 1
	else:
		l3.append(s)
		t += l2[starting_index]
		s -= 1
		starting_index += 1
l3.append(s)
print(max(l3))


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
pref = [arr[0]] + [0 for i in range(n - 1)]
for i in range(1, n):
	pref[i] = arr[i] + pref[i - 1]
pref = [0] + pref
i = 1
j = 1
final = []
while i <= n and j <= n:
	if pref[j] - pref[i - 1] <= t:
		if j == n:
			final.append(j - i + 1)
		j += 1
	elif pref[j] - pref[i - 1] > t:
		final.append(j - i)
		i += 1
print(max(final))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
maxx = 0
time = 0
last = 0
flag = True
for i in range(n):
	time += a[i]
	if time > t:
		flag = False
		time -= a[i]
		maxx = i
		last = i
		break
if flag:
	maxx = n
else:
	for i in range(1, n):
		time -= a[i - 1]
		flag = True
		for j in range(last, n):
			time += a[j]
			if time > t:
				flag = False
				maxx = max(maxx, j - i)
				time -= a[j]
				last = j
				break
		if flag:
			maxx = max(maxx, n - i)
print(maxx)


(n, t) = input().split()
n = int(n)
t = int(t)
a = [int(item) for item in input().split()]
j = 0
max_item = 0
total = 0
count = 0
for i in range(n):
	while j < n:
		total = total + a[j]
		if total > t:
			break
		else:
			count = count + 1
		j = j + 1
	max_item = max(max_item, count)
	total = total - a[i]
	j = j + 1
print(max_item)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = 0
maxx = 0
summ = 0
while r <= n:
	if r == n:
		maxx = max(maxx, r - 1 - l + 1)
		break
	if summ + a[r] > t:
		maxx = max(maxx, r - 1 - l + 1)
		summ -= a[l]
		l += 1
	else:
		summ += a[r]
		r += 1
print(maxx)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = [0] * (n + 1)
s[0] = 0
for i in range(1, n + 1):
	s[i] = s[i - 1] + l[i - 1]
last = n
no = 0
r = n
while r >= 0:
	if s[last] - s[r] > k:
		no = max(no, last - r - 1)
		last -= 1
		r += 1
	r -= 1
no = max(no, last - r - 1)
print(no)


(n, t) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
pre = []
i = 0
j = 0
s = 0
while n > j >= i:
	flag = 0
	if s + arr[j] <= t:
		s += arr[j]
		flag = 1
		j = j + 1
	else:
		pre.append(j - 1 - i + 1)
		if s > 0:
			s -= arr[i]
		if i == j:
			j += 1
		i += 1
pre.append(j - i)
print(max(pre))


def main():
	(n, t) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	be = 0
	en = -1
	time = 0
	ans = 0
	while en < n - 1:
		while time <= t and en < n - 1:
			ans = max(ans, en - be + 1)
			en += 1
			time += a[en]
		while time > t:
			time -= a[be]
			be += 1
		ans = max(ans, en - be + 1)
	print(ans)
main()


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = 0
j = 0
lcurr = 0
scurr = 0
lans = 0
while i <= n - 1 and j <= n - 1:
	scurr += a[i]
	if scurr > t:
		while scurr > t:
			scurr -= a[j]
			j += 1
	lcurr = i - j + 1
	lans = max(lans, lcurr)
	i += 1
print(lans)


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
i = 0
tam = 0
sumt = 0
dem = 0
for j in range(n):
	sumt += A[j]
	dem += 1
	while sumt > t:
		sumt -= A[i]
		i += 1
		dem -= 1
	if tam <= dem:
		tam = dem
print(tam)


def main():
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	start = stop = 0
	res = []
	try:
		while True:
			while t >= 0:
				res.append(stop - start)
				if stop == n:
					raise StopIteration
				t -= l[stop]
				stop += 1
			while t < 0:
				t += l[start]
				start += 1
	except StopIteration:
		print(max(res))
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
j = 0
k = 0
for i in range(n):
	s += a[i]
	if s > m:
		s -= a[j]
		j += 1
	k = max(k, i - j + 1)
print(k)


(nt, times) = (list(map(int, input().split())), list(map(int, input().split())))
(n, t, max, time, temp) = (nt[0], nt[1], 0, 0, 0)
for i in range(n):
	if times[i] + time <= t:
		(time, temp) = (time + times[i], temp + 1)
	else:
		break
if temp == n:
	print(temp)
	exit()
for i in range(n):
	(time, temp) = (time - times[i], temp - 1)
	for j in range(i + temp + 1, n):
		if times[j] + time <= t:
			(time, temp) = (time + times[j], temp + 1)
		else:
			break
	if max < temp:
		max = temp
print(max)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
if min(a) > t:
	print(0)
	exit(0)
ans = 0
l = min((i for i in range(n) if a[i] <= t))
r = l
s = a[l]
while l < n:
	while r + 1 < n and s + a[r + 1] <= t:
		r += 1
		s += a[r]
	ans = max(ans, r - l + 1)
	s -= a[l]
	l += 1
ans = max(ans, r - l + 1)
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
_sum = 0
cnt = 0
maxcnt = 0
for i in range(n):
	if _sum + arr[i] <= k:
		_sum += arr[i]
		cnt += 1
	elif sum != 0:
		_sum = _sum - arr[i - cnt] + arr[i]
	maxcnt = max(cnt, maxcnt)
print(maxcnt)


a = [int(x) for x in input().split()]
length = a[0]
time = a[1]
b = [int(x) for x in input().split()]
answer = 0
current_sum = 0
x = 0
while x < length:
	current_sum += b[x]
	answer += 1
	if current_sum > time:
		answer -= 1
		current_sum -= b[x - answer]
	x += 1
print(answer)


def pointers(n, t, array):
	if t <= 0:
		return 0
	(start, end) = (0, 0)
	ans = 0
	curr = 0
	while end < n:
		curr += array[end]
		while curr > t:
			curr -= array[start]
			start += 1
		ans = max(end - start + 1, ans)
		end += 1
	return ans
(n, t) = input().split()
(n, t) = (int(n), int(t))
books = list(map(int, input().split()))
print(pointers(n, t, books))


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
sum = 0
right = 0
while right < n:
	if sum + arr[right] <= t:
		sum += arr[right]
		right += 1
	else:
		break
left = 0
len = right
maxlen = right
while right < n:
	if right != left:
		sum -= arr[left]
		left += 1
		while right < n:
			if sum + arr[right] <= t:
				sum += arr[right]
				right += 1
			else:
				len = right - left
				maxlen = max(len, maxlen)
				break
			if right == n:
				len = right - left
				maxlen = max(len, maxlen)
	else:
		left += 1
		right += 1
		while right < n:
			if sum + arr[right] <= t:
				sum += arr[right]
				right += 1
			else:
				len = right - left
				maxlen = max(len, maxlen)
				break
			if right == n:
				len = right - left
				maxlen = max(len, maxlen)
print(maxlen)


(n, S) = map(int, input().split())
arr = list(map(int, input().split()))
st = 0
s = 0
maxLungime = 0
for dr in range(n):
	s += arr[dr]
	while s > S:
		s -= arr[st]
		st += 1
	if dr - st + 1 > maxLungime:
		maxLungime = dr - st + 1
print(maxLungime)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
j = 0
count = 0
m = 0
s = 0
while j < n:
	s += a[j]
	count += 1
	if count > m:
		m = count
	if s > k:
		s -= a[i]
		i += 1
		count -= 1
	j += 1
print(count)


first = list(map(int, input().split()))
books = list(map(int, input().split()))
n = first[0]
time = first[1]
l = 0
r = 0
count = 0
maxBooks = 0
tempt = 0
while r < n:
	if count + books[r] <= time:
		count += books[r]
		tempt += 1
		maxBooks = max(maxBooks, tempt)
	else:
		count -= books[l]
		count += books[r]
		if count <= time:
			maxBooks = max(maxBooks, tempt)
		l += 1
	r += 1
print(maxBooks)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
j = 0
sum = 0
res = 0
while j < n:
	sum += a[j]
	if sum > t:
		sum -= a[i]
		i += 1
	res = max(res, j - i + 1)
	j += 1
print(res)


def atMostSum(arr, n, k):
	_sum = 0
	cnt = 0
	maxcnt = 0
	for i in range(n):
		if _sum + arr[i] <= k:
			_sum += arr[i]
			cnt += 1
		elif _sum != 0:
			_sum = _sum - arr[i - cnt] + arr[i]
		maxcnt = max(cnt, maxcnt)
	return maxcnt
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
print(atMostSum(arr, n, k))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
asum = 0
j = 0
ans = 0
for i in range(n):
	asum += a[i]
	if asum > t:
		asum -= a[j]
		j += 1
	ans = max(ans, i - j + 1)
print(ans)


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
(n, k) = map(int, z().split())
l = list(map(int, z().split()))
(a, b, c) = (0, 0, 0)
for i in l:
	c += i
	if c > k:
		c -= l[b]
		b += 1
print(n - b)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
run_sum = 0
left = 0
max_len = 0
for (right, num) in enumerate(arr):
	run_sum += num
	while left <= right and run_sum > t:
		run_sum -= arr[left]
		left += 1
	max_len = max(max_len, right - left + 1)
print(max_len)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
j = 0
sumt = 0
maxl = 0
while j < len(a):
	sumt += a[j]
	if sumt <= t:
		maxl = max(maxl, j - i + 1)
		j += 1
	else:
		while sumt > t:
			sumt -= a[i]
			i += 1
		j += 1
print(maxl)


(n, t) = map(int, input().split())
b = list(map(int, input().split()))
s = b[0]
lo = hi = 0
numb = []
while hi < len(b) and lo < len(b):
	if s <= t and hi != len(b) - 1:
		hi += 1
		s += b[hi]
	elif s <= t:
		numb.append(hi - lo + 1)
		s -= b[lo]
		lo += 1
	else:
		numb.append(hi - lo)
		s -= b[lo]
		lo += 1
print(max(numb))


def main():
	nm = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	s = input().split(' ')
	result = 0
	l = 0
	r = 0
	temp = 0
	for i in range(n):
		temp += int(s[i])
		if temp <= m:
			r = i
			result = max((r - l + 1, result))
		else:
			temp -= int(s[l])
			l = l + 1
	print(result)
main()


(n, t) = map(int, input().split())
al = list(map(int, input().split()))
al = [0] + al
for i in range(1, n + 1):
	al[i] += al[i - 1]
j = 1
su = 0
ans = 0
for i in range(1, n + 1):
	while j <= n and al[j] - al[i - 1] <= t:
		j += 1
	ans = max(ans, j - i)
print(ans)


datain = True
if datain:
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
else:
	(n, t) = (3, 3)
	a = [2, 2, 3]
le = 0
ri = -1
sa = len(a)
x0 = 0
y0 = 0
time = 0
while ri + 1 < sa and time + a[ri + 1] <= t:
	time += a[ri + 1]
	ri += 1
if ri == sa - 1:
	if ri != 0:
		print(ri - le + 1)
	elif a[ri] < t:
		print('1')
	else:
		print('0')
else:
	for le in range(sa):
		time -= a[le]
		while ri + 1 < sa and time + a[ri + 1] <= t:
			time += a[ri + 1]
			ri += 1
		if ri - le > y0 - x0:
			(x0, y0) = (le, ri)
		if ri == sa - 1:
			break
	print(y0 - x0)


(n, t) = map(int, input().split())
lis = list(map(int, input().split()))
tot = 0
k = 0
for i in lis:
	tot = tot + i
	if tot > t:
		tot = tot - lis[k]
		k = k + 1
print(n - k)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
c = 0
j = 0
d = 0
for i in range(n):
	s += a[i]
	if s <= m:
		c += 1
	else:
		s -= a[j]
		d = max(d, c)
		j += 1
d = max(d, c)
print(d)


def MaxSum(a, k):
	cnt = ans = su = 0
	for i in range(len(a)):
		if su + ls[i] <= k:
			su += ls[i]
			cnt += 1
		elif su != 0:
			su = su - ls[i - cnt] + ls[i]
		ans = max(cnt, ans)
	return ans
(n, t) = map(int, input().split())
ls = [int(x) for x in input().split()]
print(MaxSum(ls, t))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
ma = 0
j = 0
su = 0
for i in range(n):
	su += a[i]
	if su > t:
		while su > t and j < n:
			su -= a[j]
			j += 1
	ma = max(ma, i - j + 1)
print(ma)


(n, lim) = map(int, input().split())
ls = list(map(int, input().split()))
i = 0
j = 1
s = ls[0]
ans = int(s <= lim)
while j < n:
	if s <= lim or i == j:
		j += 1
		s += ls[j - 1]
	else:
		s -= ls[i]
		i += 1
	if s <= lim:
		ans = max(ans, j - i)
print(ans)


(n, time_limit) = map(int, input().split())
book = list(map(int, input().split()))
readingTime = count = ans = i = j = 0
while i < n:
	if readingTime + book[i] <= time_limit:
		readingTime += book[i]
		count += 1
		ans = max(ans, count)
		i += 1
	else:
		readingTime -= book[j]
		j += 1
		count -= 1
print(ans)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, t) = zz()
li = zzz()
(l, r) = (0, n - 1)
m = 0
s = 0
for i in range(n):
	s += li[i]
	if s > t:
		s -= li[l]
		l += 1
	else:
		m = max(m, i - l + 1)
print(m)


(n, t) = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = 0
j = 0
for i in range(n):
	ans += l[i]
	if ans > t:
		ans -= l[j]
		j += 1
print(i - j + 1)


def book():
	par1 = list(map(int, input().split()))
	par2 = list(map(int, input().split()))
	books = par1[0]
	minutes = par1[1]
	j = 0
	count = 0
	vmax = 0
	for i in range(0, books):
		while minutes < par2[i]:
			minutes = minutes + par2[j]
			j = j + 1
			count = count - 1
		minutes = minutes - par2[i]
		count = count + 1
		vmax = max(vmax, count)
	return vmax
print(book())


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
(n, t) = rinput()
a = get_list()
(s, j) = (0, 0)
ans = 0
for i in range(n):
	s += a[i]
	if s > t:
		s -= a[j]
		j += 1
print(n - j)


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
a = 0
bt = c = x = 0
for i in range(n):
	if bt + b[i] > k:
		a = max(a, x)
		bt = bt - b[c]
		c += 1
		if b[i] == k:
			a = max(a, 1)
			bt = x = 0
			c = i + 1
		elif b[i] > k:
			bt = x = 0
			c = i + 1
		else:
			while bt + b[i] > k:
				bt -= b[c]
				c += 1
				x -= 1
			bt += b[i]
	else:
		bt += b[i]
		x += 1
a = max(a, x)
print(a)


def maxBooks1(n, t, arr):
	mx = 0
	for i in range(0, n):
		for j in range(i, n):
			sum = 0
			for k in range(i, j + 1):
				sum += arr[k]
			segmenLen = j - i + 1
			if sum <= t and segmenLen > mx:
				mx = segmenLen
	return mx

def maxBooks2(n, t, arr):
	mx = 0
	for i in range(0, n):
		sum = 0
		for j in range(i, n):
			sum += arr[j]
			segmenLen = j - i + 1
			if sum <= t and segmenLen > mx:
				mx = segmenLen
	return mx

def maxBooks3(n, t, arr):
	mx = 0
	i = 0
	sum = 0
	for j in range(0, n):
		sum += arr[j]
		while sum > t:
			sum -= arr[i]
			i += 1
		segmenLen = j - i + 1
		if segmenLen > mx:
			mx = segmenLen
	return mx
(n, t) = input().split(' ')
n = int(n)
t = int(t)
arr = input().split(' ')
arr = [int(x) for x in arr]
print(maxBooks3(n, t, arr))


from typing import List

def solution(t: int, books: List[int]):
	best_count = 0
	start = 0
	end = 0
	window_sum = books[0]
	while start < len(books):
		while end + 1 < len(books):
			if window_sum + books[end + 1] <= t:
				end += 1
				window_sum += books[end]
			else:
				break
		if window_sum <= t:
			best_count = max(best_count, end - start + 1)
		window_sum -= books[start]
		start += 1
		end += 1
		if end < len(books):
			window_sum += books[end]
	return best_count

def get_arr():
	return [int(x) for x in input().split()]

def main():
	(n, t) = get_arr()
	books = get_arr()
	print(solution(t, books))
main()


def solve(n, t, a):
	time = 0
	res = 0
	j = 0
	for i in range(n):
		if time + a[i] <= t:
			time += a[i]
		else:
			time += a[i]
			while time > t:
				time -= a[j]
				j += 1
		res = max(res, i + 1 - j)
	return res
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, t, a))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
mx = 0
l = 0
r = 0
sm = 0
count = 0
while l < n:
	while sm + a[r] <= t:
		sm += a[r]
		count += 1
		r += 1
		if r == n:
			break
	if count > mx:
		mx = count
	if r == n:
		break
	sm -= a[l]
	count -= 1
	l += 1
print(mx)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
books = left = runSum = 0
for right in range(n):
	runSum += a[right]
	while runSum > t:
		runSum -= a[left]
		left += 1
	books = max(books, right - left + 1)
print(books)


(n, t) = map(int, input().split())
books = list(map(int, input().split()))
(sums, dp) = ([0] * n, [0] * n)
sums[0] = books[0]
for i in range(1, n):
	sums[i] = sums[i - 1] + books[i]
(left, right) = (0, 0)
while right < n:
	if sums[right] - sums[left] + books[left] <= t:
		dp[right] = right - left + 1
		right += 1
	else:
		while left <= right and sums[right] - sums[left] + books[left] > t:
			left += 1
		if left > right:
			right += 1
print(max(dp))


(n, s) = map(int, input().split())
l = list(map(int, input().split()))
i = 0
j = 0
ans = 0
temp = 0
while i < n and j < n:
	temp += l[i]
	if temp <= s:
		ans = max(ans, i - j + 1)
	else:
		while j <= i and temp > s:
			temp -= l[j]
			j += 1
	i += 1
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
j = 0
m = 0
s = 0
while i < n:
	if a[i] + s <= t:
		s += a[i]
		i += 1
		m = max(m, abs(i - j))
	else:
		s -= a[j]
		j += 1
print(m)


(numberOfBooks, timeLeft) = map(int, input().split())
times = list(map(int, input().split()))
counter = 0
c = 0
for i in range(numberOfBooks):
	counter += times[i]
	if counter > timeLeft:
		counter -= times[c]
		c += 1
print(len(times) - c)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
count = 0
maxBooks = 0
x = 0
for i in range(n):
	maxBooks += a[i]
	count += 1
	if maxBooks > t:
		maxBooks -= a[x]
		x += 1
		count -= 1
print(count)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(left, right) = (0, 0)
s = 0
res = 0
while left < n:
	while right < n and s + a[right] <= t:
		s += a[right]
		right += 1
	res = max(res, right - left)
	s -= a[left]
	left += 1
print(res)


(a, b) = map(int, input().rstrip().split())
l = list(map(int, input().split()))
(start, maxi) = (0, 0)
cur_sum = l[0]
for i in range(1, a + 1):
	while cur_sum > b and start < i - 1:
		cur_sum = cur_sum - l[start]
		start += 1
	if cur_sum <= b:
		maxi = max(maxi, i - start)
	if i < a:
		cur_sum += l[i]
print(maxi)


(n, t) = map(int, input().split())
lis = list(map(int, input().split()))
aa = [0] * (n + 1)
for i in range(1, n + 1):
	aa[i] = lis[i - 1] + aa[i - 1]
i = 0
j = 1
ans = 0
aa.append(t + 1)
while i < n and j <= n:
	s = aa[min(j, n)] - aa[i]
	if s <= t:
		ans = max(ans, j - i)
		j += 1
	else:
		i += 1
print(ans)


from sys import stdin
(n, k) = map(int, stdin.readline().rstrip().split(' '))
l = list(map(int, stdin.readline().rstrip().split(' ')))
res = s = start = 0
for i in range(n):
	s += l[i]
	while s > k:
		s -= l[start]
		start += 1
	res = max(res, i - start + 1)
print(res)


def main():
	(N, T) = map(int, input().split())
	books = list(map(int, input().split()))
	leftIndex = 0
	rightIndex = 0
	totalTime = 0
	currentBooks = 0
	maximumBooks = 0
	while rightIndex < N:
		totalTime += books[rightIndex]
		currentBooks += 1
		if totalTime > T:
			totalTime -= books[leftIndex]
			leftIndex += 1
			currentBooks -= 1
		elif currentBooks > maximumBooks:
			maximumBooks = currentBooks
		rightIndex += 1
	print(maximumBooks)
	return True
main()


a = list(map(int, input().split(' ')))
n = int(a[0])
t = int(a[1])
books = list(map(int, input().split(' ')))
time = 0
count = 0
arr = []
for i in range(n):
	if time + books[i] <= t:
		time += books[i]
		count += 1
	else:
		break
arr.append([count, time])
for i in range(1, n):
	(prevc, prevt) = (arr[i - 1][0], arr[i - 1][1])
	ct = prevt - books[i - 1]
	cc = prevc - 1
	for j in range(prevc + i - 1, n):
		if ct + books[j] <= t:
			ct += books[j]
			cc += 1
		else:
			break
	arr.append([cc, ct])
b = []
for a in arr:
	b.append(a[0])
print(max(b))


(n, t) = map(int, input().split())
books = list(map(int, input().split()))
accumulatedTimes = []
summa = 0
for i in books:
	summa += i
	accumulatedTimes.append(summa)
bestSoFar = 0
for i in range(n):
	lo = i
	hi = len(accumulatedTimes) - 1
	currentTime = 0
	if i == 0:
		startvalue = 0
	else:
		startvalue = accumulatedTimes[i - 1]
	while lo < hi:
		mid = lo + (hi - lo + 1) // 2
		if accumulatedTimes[mid] - startvalue <= t:
			lo = mid
		else:
			hi = mid - 1
	if accumulatedTimes[lo] - startvalue <= t:
		bestSoFar = max(bestSoFar, lo - i + 1)
print(bestSoFar)


(n, t) = map(int, input().split())
arrN = list(map(int, input().split()))
result = 0
result = 0
totalTime = 0
j = 0
i = 0
while i < n:
	totalTime += arrN[i]
	if totalTime <= t:
		tempResult = i - j + 1
		result = max(result, tempResult)
	else:
		while totalTime > t:
			totalTime -= arrN[j]
			j += 1
	i += 1
print(result)


def max_books(arr, n, t, s):
	j = 0
	temp = 0
	for i in range(n):
		temp += arr[i]
		if temp > t:
			temp -= arr[j]
			j += 1
	return n - j
(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
s = sum(arr)
print(max_books(arr, n, t, s))


(books, minutes) = map(int, input().split())
a_minutes = list(map(int, input().split()))
c = 0
tmp_times = 0
tmp_c = 0
for i in range(books):
	if tmp_times + a_minutes[i] <= minutes:
		c += 1
		tmp_times += a_minutes[i]
	else:
		break
tmp_c = c
for j in range(books):
	tmp_times -= a_minutes[j]
	while tmp_c < books and tmp_times + a_minutes[tmp_c] <= minutes:
		tmp_times += a_minutes[tmp_c]
		tmp_c += 1
	if tmp_c - j - 1 > c:
		c = tmp_c - j - 1
print(c)


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
j = -1
s = 0
ans = 0
for i in range(n):
	if s + a[i] <= t:
		s += a[i]
	else:
		s += a[i]
		while s > t:
			j += 1
			s -= a[j]
	ans = max(ans, i - j)
print(ans)


(n, t) = list(map(int, input().split()))
tlist = [int(t) for t in input().split()]
maxcount = 0
time = 0
i = 0
j = 0
count = 1
while j != n:
	if time + tlist[j] <= t:
		time += tlist[j]
		if maxcount < count:
			maxcount = count
		j += 1
		count += 1
	else:
		time -= tlist[i]
		i += 1
		count -= 1
print(maxcount)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = a[0]
i = 0
j = 0
b = []
for i in range(n):
	while s < t and j < n - 1:
		j += 1
		s += a[j]
	if s > t:
		b.append(j - i)
	else:
		b.append(j - i + 1)
	s -= a[i]
b.sort(reverse=True)
print(b[0])


arr = [0] * 200000
tt = [0] * 200000
ans = 0
nt = input().split()
n = int(nt[0])
t = int(nt[1])
isi = input().split()
for i in range(1, n + 1, 1):
	arr[i] = int(isi[i - 1])
kiri = 1
r = 0
for i in range(1, n + 1, 1):
	if arr[i] <= t:
		kiri = i
		r = i
		break
tt[kiri - 1] = 2 * arr[kiri]
arr[kiri - 1] = arr[kiri]
for i in range(kiri, n + 1, 1):
	kiri = i
	tt[i] = tt[i - 1] - arr[i - 1]
	for j in range(r + 1, n + 1, 1):
		if tt[i] + arr[j] <= t:
			tt[i] += arr[j]
			r = j
		else:
			r = j - 1
			break
	if ans < r - kiri + 1:
		ans = r - kiri + 1
print(ans)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
i = j = 0
sm = 0
mx = 0
while j < n:
	sm += arr[j]
	while sm > t:
		sm -= arr[i]
		i += 1
	mx = max(mx, j - i + 1)
	j += 1
print(mx)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
from itertools import accumulate
pref = [0] + list(accumulate(a))
r = 1
ans = 0
for l in range(1, n + 1):
	while r <= n and pref[r] - pref[l - 1] <= t:
		r += 1
	ans = max(ans, r - l)
print(ans)


def sm(l, r):
	if l > 0:
		return ps[r] - ps[l - 1]
	else:
		return ps[r]

def prov(mid):
	r = mid - 1
	l = 0
	while r < len(a):
		if sm(l, r) <= t:
			return 1
		r += 1
		l += 1
	return 0
(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ps = [a[0]]
for i in range(1, len(a)):
	ps.append(ps[i - 1] + a[i])
left = 0
right = n + 1
while right - left > 1:
	mid = (left + right) // 2
	if prov(mid) == 1:
		left = mid
	else:
		right = mid
print(left)


(n, t) = map(int, input().split())
A = [int(x) for x in input().split()]
(a, b, j) = (0, 0, 0)
for i in range(n):
	while A[i] > t:
		t += A[j]
		j += 1
		b -= 1
	t -= A[i]
	b += 1
	a = max(a, b)
print(a)


from collections import deque
queue = deque()
(n, t) = map(int, input().split())
mins = list(map(int, input().split()))
(sol, s, size) = (0, 0, 0)
for m in mins:
	s += m
	queue.append(m)
	size += 1
	while s > t:
		s -= queue.popleft()
		size -= 1
	sol = max(sol, size)
print(sol)


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
last = total_time = 0
while last < n and total_time + A[last] <= t:
	(total_time, last) = (total_time + A[last], last + 1)
max_books = last
for first in range(1, n):
	(total_time, last) = (max(0, total_time - A[first - 1]), max(first, last))
	while last < n and total_time + A[last] <= t:
		(total_time, last) = (total_time + A[last], last + 1)
	max_books = max(last - first, max_books)
	if last == n:
		break
print(max_books)


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
j = 0
bc = 0
maxbc = 0
tempt = 0
for i in range(n):
	if j == n:
		break
	while j < n:
		tempt = tempt + a[j]
		bc = bc + 1
		j = j + 1
		if tempt > t:
			tempt = tempt - a[i]
			bc = bc - 1
			break
		else:
			maxbc = max(bc, maxbc)
print(maxbc)


ans = 0
m = 0
b = list(map(int, input().split()))
n = b[0]
t = b[1]
a = list(map(int, input().split()))
f = []
for i in range(0, n + 3):
	f.append(0)
for i in range(0, n):
	f[i + 1] = f[i] + a[i]
	if f[i + 1] - f[m] > t:
		m += 1
	ans = max(ans, i + 1 - m)
print(ans)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
if n == 1 and a[0] <= t:
	print(1)
	exit()
result = 0
buf = 0
for i in range(n):
	if buf + a[i] > t:
		break
	buf += a[i]
	result += 1
for i in range(n):
	if i + result >= n:
		break
	buf = buf - a[i] + a[i + result]
	while True:
		if i + result + 1 >= n:
			break
		if buf + a[i + result + 1] > t:
			break
		buf += a[i + result + 1]
		result += 1
print(result)


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
i = 0
j = 0
m = 0
count = 0
while j < len(l):
	if l[j] <= b:
		count += 1
		b -= l[j]
		j = j + 1
		m = max(m, count)
	elif i < j:
		b += l[i]
		count -= 1
		i = i + 1
	else:
		i += 1
		j += 1
print(m)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
arr = []
for i in range(n):
	s += a[i]
	arr.append(s)

def binary(arr, mid, n, t):
	start = 0
	end = n - 1
	while start <= end:
		pivot = (start + end) // 2
		if arr[pivot] - mid <= t:
			start = pivot + 1
		else:
			end = pivot - 1
	return end
m = binary(arr, 0, n, t) + 1
for i in range(1, n):
	temp = binary(arr, arr[i - 1], n, t) - i + 1
	m = max(temp, m)
print(m)


(n, t) = [int(x) for x in input().split()]
books = [int(x) for x in input().split()]
s = 0
j = 0
for i in range(n):
	s = s + books[i]
	if s > t:
		s = s - books[j]
		j = j + 1
print(n - j)


(n, t) = [int(i) for i in input().split()]
a = [0] + [int(i) for i in input().split()]
b = []
naswer = 0
noswer = 0
nul = 0
for i in a:
	nul = nul + i
	b.append(nul)
for i in range(1, n + 1):
	l = i - 1
	r = n + 1
	while r - l > 1:
		mid = (l + r) // 2
		noswer = b[mid] - b[i - 1]
		if noswer <= t:
			l = mid
		else:
			r = mid
	naswer = max(naswer, l - i + 1)
print(naswer)


import random

def read_tokens():
	return input().strip().split(' ')

def read_ints():
	return [int(s) for s in read_tokens()]
(n, t) = read_ints()
arr = read_ints()

def slow(arr, t) -> int:
	n = len(arr)
	max_size = 0
	for i in range(n):
		for j in range(i, n):
			sub = arr[i:j + 1]
			sub_sum = sum(sub)
			curr_size = j - i + 1
			if curr_size > max_size and sub_sum <= t:
				max_size = curr_size
	return max_size

def fast(a, t) -> int:
	n = len(a)
	l = 0
	max_size = 0
	curr_sum = 0
	for r in range(n):
		curr_sum += a[r]
		while curr_sum > t:
			curr_sum -= a[l]
			l += 1
		max_size = max(max_size, r - l + 1)
	return max_size
print(fast(arr, t))

def check(arr: list, t: int, expected: int):
	actual = fast(arr, t)
	if actual != expected:
		print(f'bad : {actual}, {expected}')
		raise Exception('failed test')
	else:
		print('good')

def test():
	begin = 0
	end = 1000
	i = 0
	while True:
		i += 1
		if i % 100 == 0:
			print(i)
		n = random.randint(begin, end)
		a = [0] * n
		for i in range(n):
			a[i] = random.randint(begin, end)
		t = random.randint(begin, end)
		check(a, t, slow(a, t))


(n, l) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
(i, j) = (-1, 0)
(s, ans) = (0, 0)
while j != n:
	s = s + a[j]
	while s > l:
		i = i + 1
		s = s - a[i]
	if j - i > ans:
		ans = j - i
	j = j + 1
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = j = 0
ans = 0
temp = 0
while j < n:
	if t >= a[j]:
		temp += 1
		t -= a[j]
		j += 1
	elif i + 1 < n:
		t += a[i] if i < j else 0
		i += 1
		ans = max(temp, ans)
		temp = temp - 1 if i <= j else 0
		j = max(j, i)
	else:
		break
ans = max(ans, temp)
print(ans)


(n, t) = map(int, input().split())
A = [int(i) for i in input().split()]
sum1 = 0
(i, j) = (0, 0)
k = t - A[0]
if k > 0:
	sum1 = 1
while i < n - 1 and j < n - 1:
	if A[j + 1] <= k:
		j += 1
		k -= A[j]
		if sum1 < j - i + 1:
			sum1 = j - i + 1
	else:
		i += 1
		k += A[i - 1]
print(sum1)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, t) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	low = 0
	high = n
	mid = 0

	def pos(midd):
		temp = sum(a[:midd])
		if temp <= t:
			return True
		for x in range(midd, n):
			temp = temp - a[x - midd] + a[x]
			if temp <= t:
				return True
		return False
	while low <= high:
		mid = (low + high) // 2
		if pos(mid) == True and pos(mid + 1) == False:
			break
		elif pos(mid) == True:
			low = mid + 1
		else:
			high = mid - 1
	print(mid)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os, sys
from io import BytesIO, IOBase
from bisect import bisect

def main():
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	cul = [0]
	for i in range(n):
		cul.append(cul[-1] + a[i])
	maxi = 0
	for i in range(n):
		val = cul[i] + t
		z = bisect(cul, val)
		maxi = max(maxi, z - i - 1)
	print(maxi)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, t) = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
c = 0
c1 = 0
c2 = 0
s = 0
while c2 != n:
	if s + l[c2] > t:
		c = max(c2 - c1, c)
		s = max(0, s - l[c1])
		c1 += 1
		c2 = max(c1, c2)
	else:
		s += l[c2]
		c2 += 1
c = max(c2 - c1, c)
print(c)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
time = t
mb = 0
i = 0
j = 0
m = 0
cur = 0
while j < n and i < n:
	if t >= a[j]:
		t -= a[j]
		j += 1
		cur += 1
	else:
		t += a[i]
		i += 1
		cur -= 1
	m = max(m, cur)
print(m)


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
m = 0
(i, j) = (0, 0)
for j in range(n):
	m = m + a[j]
	if m > t:
		m = m - a[i]
		i += 1
print(len(a) - 1 - i + 1)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
(sums, i, j) = (0, 0, 0)
for i in range(len(arr)):
	sums += arr[i]
	if sums > t:
		sums -= arr[j]
		j += 1
print(n - j)


(n, T) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
sum = 0
l = 0
res = 0
for i in range(n):
	sum += a[i]
	while sum > T:
		sum -= a[l]
		l += 1
	if res < i - l + 1:
		res = i - l + 1
print(res)


(n, m) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
j = 0
sum1 = 0
for i in range(n):
	sum1 = sum1 + a[i]
	if sum1 > m:
		sum1 = sum1 - a[j]
		j += 1
print(n - j)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
sum1 = 0
maxbooks = 0
p1 = 0
p2 = 0
while p1 < n and p2 < n:
	if sum1 + a[p2] > t:
		maxbooks = max(maxbooks, p2 - p1)
		sum1 = max(0, sum1 - a[p1])
		p1 += 1
	else:
		sum1 += a[p2]
		p2 += 1
	if p2 < p1:
		p2 = p1
print(max(maxbooks, p2 - p1))


(n, t) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
(z, c) = (0, 0)
for i in range(n):
	if z + arr[i] <= t:
		z = z + arr[i]
		c += 1
	else:
		break
l = 0
r = c
if c == n:
	print(c)
	exit()
read = []
read.append(c)
aa = 0
for i in range(1, n):
	z = z - arr[l]
	l += 1
	c -= 1
	for j in range(r, n):
		if z + arr[j] <= t:
			z = z + arr[j]
			c += 1
			aa = j
			if j == n - 1:
				aa = j + 1
		else:
			aa = j
			break
	read.append(c)
	r = aa
print(max(read))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
psum = [0] * n
psum[0] = a[0]
for i in range(1, n):
	psum[i] = psum[i - 1] + a[i]
ans = 0
for i in range(0, n):
	(lo, hi) = (i, n - 1)
	while lo < hi:
		mid = lo + (hi - lo + 1) // 2
		if psum[mid] - psum[i] + a[i] <= t:
			lo = mid
		else:
			hi = mid - 1
	if psum[lo] - psum[i] + a[i] <= t:
		ans = max(ans, lo - i + 1)
print(ans)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
a.insert(0, 0)
ans = 0
for i in range(1, n + 1):
	a[i] += a[i - 1]
i = 1
j = 1
while i <= n and j <= n:
	while j <= n:
		if a[j] - a[i - 1] > t:
			break
		j += 1
	ans = max(ans, j - i)
	i += 1
print(ans)


(n, t) = map(int, input().split())
books = [int(i) for i in input().split()]
ans = 0
tmp_ans = 0
count = 0
i = 0
j = i
while i < n:
	if books[i] > t:
		j = i
		if ans < tmp_ans:
			ans = tmp_ans
		tmp_ans = 0
	else:
		count += books[i]
		if count <= t:
			tmp_ans += 1
		else:
			while count > t:
				count -= books[j]
				j += 1
			if ans < tmp_ans:
				ans = tmp_ans
			tmp_ans = i - j + 1
	i += 1
if tmp_ans > ans:
	print(tmp_ans)
else:
	print(ans)


(a, b) = map(int, input().split())
s = list(map(int, input().split()))
l = 0
j = 0
p = 0
for n in range(a):
	if p + s[n] <= b:
		p += s[n]
		j += 1
	else:
		p -= s[l]
		l += 1
		p += s[n]
print(j)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
ct = 0
high = 0
le = 0
ri = 0
try:
	while True:
		if a[ri] + s > t:
			if ct > high:
				high = ct
			s -= a[le]
			le += 1
			ct -= 1
		s += a[ri]
		ri += 1
		ct += 1
except IndexError:
	if ct > high:
		high = ct
	print(high)


(n, time) = [int(x) for x in input().split()]
mins = [int(x) for x in input().split()]
p1 = 0
p2 = 1
cantidad = 1
tiempo = mins[0]
maximo = 1
if min(mins) > time:
	print(0)
else:
	while p2 != len(mins) and p1 != len(mins):
		if tiempo > time:
			tiempo -= mins[p1]
			p1 += 1
			tiempo += mins[p2]
			p2 += 1
			cantidad = p2 - p1
		else:
			cantidad = p2 - p1
			if cantidad > maximo:
				maximo = cantidad
			tiempo += mins[p2]
			p2 += 1
			cantidad = p2 - p1
	if cantidad > maximo and tiempo <= time:
		maximo = cantidad
	print(maximo)


def f():
	return [int(i) for i in input().split()]
([n, t], a) = (f(), f())
max_read = 0
books_read = 0
time = 0
for i in range(n):
	if books_read > 0:
		books_read -= 1
		time -= a[i - 1]
		i += books_read
	for j in range(i, n):
		if time + a[j] <= t:
			time += a[j]
			books_read += 1
			if books_read > max_read:
				max_read = books_read
		else:
			break
print(max_read)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
(ind, s) = (0, 0)
for i in range(n):
	s += a[i]
	if s > t:
		s -= a[ind]
		ind += 1
print(n - ind)


a1 = [int(s) for s in input().split()]
a2 = [int(s) for s in input().split()]
nullArray = [0]
a2 = nullArray + a2
i = 0
j = 0
minutes = a1[1]
runningTotal = 0
maximum = 0
for i in range(0, len(a2)):
	runningTotal -= a2[i]
	while j + 1 < len(a2) and runningTotal + a2[j + 1] <= minutes:
		j += 1
		runningTotal += a2[j]
	score = j - i
	if score > maximum:
		maximum = score
print(maximum)


(nb_books, has_time) = [int(x) for x in input().split()]
time_needed = [int(x) for x in input().split()]
(idx, done) = (0, 0)
for i in range(nb_books):
	done += time_needed[i]
	if done > has_time:
		done -= time_needed[idx]
		idx += 1
print(nb_books - idx)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
l = [0]
j = 0
max = 0
for i in range(n):
	l.append(l[-1] + a[i])
	if l[i + 1] - l[j] > t:
		j += 1
	if i + 1 - j > max:
		max = i + 1 - j
print(max)


def maxBookRead(book_minutes, quota):
	i = 0
	j = 0
	total_minutes = book_minutes[0]
	max_book = 0
	while i <= len(book_minutes) - 1 and j <= len(book_minutes) - 1:
		count = j - i + 1
		while total_minutes <= quota and j < len(book_minutes) - 1:
			j += 1
			total_minutes += book_minutes[j]
			count += 1
		if total_minutes > quota:
			count -= 1
		if max_book < count:
			max_book = count
		total_minutes -= book_minutes[i]
		i += 1
	return max_book
(n, m) = list(map(int, input().split()))
book_minutes = list(map(int, input().split()))
print(maxBookRead(book_minutes, m))


l = input().split()
n = int(l[0])
m = int(l[1])
l = input().split()
for i in range(0, n):
	l[i] = int(l[i])
result = 0
i = 0
j = 0
sum = l[0]
num = 1
try:
	while i < n and j < n:
		if sum > m:
			sum -= l[i]
			num -= 1
			if j == i:
				j += 1
				sum += l[j]
				num += 1
			i += 1
		else:
			result = max(result, num)
			j += 1
			sum += l[j]
			num += 1
except IndexError:
	pass
print(result)


n = input()
n = n.split()
n = list(map(int, n))
t = n[1]
n = n[0]
ai = input()
ai = ai.split()
ai = list(map(int, ai))
leftI = 0
rightI = 0
totalTime = 0
count = 0
maxm = 0
while rightI < n:
	if totalTime + ai[rightI] <= t:
		totalTime += ai[rightI]
		rightI += 1
		count += 1
		if count > maxm:
			maxm = count
	else:
		totalTime = max(totalTime - ai[leftI], 0)
		leftI += 1
		rightI = max(leftI, rightI)
		count = max(count - 1, 0)
print(maxm)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
count = sum = i = 0
while i < n:
	if sum + a[i] > k:
		break
	sum += a[i]
	i += 1
c = i
j = i
while j < n:
	count += 1
	sum += a[j] - a[count - 1]
	if sum < k:
		j += 1
		if j >= n:
			break
		while sum + a[j] <= k:
			sum += a[j]
			c += 1
			j += 1
			if j >= n:
				break
	else:
		j += 1
print(c)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
books = 0
sum = 0
k = 0
for i in range(n):
	sum += a[i]
	if sum <= t:
		books += 1
	else:
		sum -= a[k]
		k += 1
print(books)


(n, t) = map(int, input().split())
books = list(map(int, input().split()))
s = i = j = 0
ans = 0
while i < n and j < n:
	if s + books[j] <= t:
		s += books[j]
		j += 1
	else:
		s -= books[i]
		i += 1
	ans = max(ans, j - i)
print(ans)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
from itertools import accumulate
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
psum = accumulate(arr)
m = 0
ptr1 = 0
ptr2 = 0
temp = 0
count = 0
while ptr2 < n:
	temp += arr[ptr2]
	count += 1
	ptr2 += 1
	if temp > t:
		temp -= arr[ptr1]
		ptr1 += 1
		count -= 1
	m = max(count, m)
print(m)


(n, t) = map(int, input().split())
a = [int(a) for a in map(int, input().split())]
j = x = 0
for i in range(n):
	x += a[i]
	if x > t:
		x -= a[j]
		j += 1
print(n - j)


def soln(arr, t):
	result = 0
	(L, R) = (0, 0)
	currSum = 0
	while R < len(arr):
		if currSum + arr[R] <= t:
			currSum += arr[R]
			R += 1
			result = max(result, R - L)
		else:
			currSum -= arr[L]
			L += 1
	return result

def main():
	(n, t) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	result = soln(arr, t)
	print(result)
main()


(n, t) = map(int, input().split())
minutes = [i for i in map(int, input().split())]
count = 0
max_count = 0
sum_min = 0
i = 0
j = 0
while j < n:
	if sum_min + minutes[j] <= t:
		sum_min += minutes[j]
		j += 1
		count += 1
		if count > max_count:
			max_count = count
	else:
		sum_min -= minutes[i]
		i += 1
		count = j - i
print(max_count)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
cur_time = 0
maxb = 0
numb = 0
j = 0
for i in range(n):
	cur_time += a[i]
	numb += 1
	while cur_time > t:
		cur_time -= a[j]
		j += 1
		numb -= 1
	maxb = max(maxb, numb)
print(maxb)


(n, m) = map(int, input().split())
d = list(map(int, input().split()))
s = 0
r = 0
i = j = 0
ans = 0
while i < n and j < n:
	if s + d[j] <= m:
		r += 1
		s += d[j]
		j += 1
	else:
		r = max(r - 1, 0)
		s = max(s - d[i], 0)
		i += 1
		j = max(i, j)
	ans = max(ans, r)
print(ans)


from math import *
from collections import *
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
pre = [0, a[0]]
for i in range(1, n):
	pre.append(pre[-1] + a[i])
i = 0
j = 1
maxx = 0
while i < n:
	while j <= n and pre[j] - pre[i] <= m:
		j += 1
	maxx = max(maxx, j - i - 1)
	i += 1
print(maxx)


from sys import stdin, stdout
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import deque
(n, t) = mp()
l = mp()
(i, count) = (0, 0)
(s, ans) = (0, 0)
j = 0
while i < n:
	s += l[i]
	count += 1
	if s > t:
		count -= 1
		ans = max(ans, count)
		s -= l[j]
		j += 1
	elif s == t:
		ans = max(ans, count)
		count -= 1
		s -= l[j]
		j += 1
	i += 1
ans = max(ans, count)
print(ans)


def index_floor(ordered, n, finding):
	first = 0
	last = n
	while last - first > 1:
		mid = (first + last) // 2
		if finding < ordered[mid]:
			last = mid
		else:
			first = mid
	return first
aiya = input().split()
n = int(aiya[0])
t = int(aiya[1])
nums = input().split()
for i in range(n):
	nums[i] = int(nums[i])
sums = [0 for x in range(n)]
for i in range(n):
	if i == 0:
		sums[0] = nums[0]
	else:
		sums[i] = sums[i - 1] + nums[i]
sums.insert(0, 0)
high = 0
for i in range(n + 1):
	dif = index_floor(sums, n + 1, sums[i] + t) - i
	high = max(high, dif)
print(high)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
(right, left, books, sum) = (0, 0, 0, 0)
while left != n:
	sum += a[left]
	if sum <= t and books < left + 1 - right:
		books = left + 1 - right
	elif sum > t:
		sum -= a[right]
		right += 1
	left += 1
print(books)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(read_time, j, max_book) = (0, 0, 0)
for i in range(n):
	read_time += a[i]
	while read_time > t:
		read_time -= a[j]
		j += 1
	max_book = max(max_book, i - j + 1)
print(max_book)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l.reverse()
a = [0] * n
a[0] = l[0]
for i in range(1, n):
	a[i] = l[i] + a[i - 1]
a = a + [0]
(p, q) = (0, -1)
maxx = 0
while p < n:
	if a[p] - a[q] < m:
		p += 1
		maxx = max(p - 1 - q, maxx)
	elif a[p] - a[q] == m:
		if p - q > maxx:
			maxx = p - q
		p += 1
		q += 1
	else:
		maxx = max(p - 1 - q, maxx)
		q += 1
print(maxx)


import math

def facts(n):
	ans = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			ans.append(i)
			ans.append(n // i)
	ans = sorted(list(dict.fromkeys(ans)))
	if ans[-1] == n:
		ans = ans[:-1]
	return ans
(n, m) = map(int, input().split())
bs = list(map(int, input().split()))
mx = 0
tmp = 0
pnt = -1
for i in range(n):
	tmp += bs[i]
	while tmp > m:
		pnt += 1
		tmp -= bs[pnt]
	mx = max(mx, i - pnt)
print(mx)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
suma = 0
start = 0
count = 0
for i in range(n):
	suma += arr[i]
	if suma <= t:
		count += 1
	else:
		suma -= arr[start]
		start += 1
print(count)


def solve(n, t, a):
	A = 0
	b = 0
	for i in range(n):
		A += a[i]
		if A > t:
			A -= a[b]
			b += 1
	ans = n - b
	return ans
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, t, a))


def solution():
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	l = len(a)
	if l < 2:
		if a[0] <= t:
			print(1)
		else:
			print(0)
		return
	result = []
	firstIndex = 0
	totalMinute = a[firstIndex]
	totalBook = 0
	previousFirst = firstIndex
	while firstIndex != n:
		if totalMinute <= t:
			totalBook += 1
		else:
			result.append(totalBook)
			totalMinute -= a[previousFirst]
			previousFirst += 1
		firstIndex += 1
		if firstIndex == n:
			result.append(totalBook)
			break
		totalMinute += a[firstIndex]
	result.sort()
	print(result[len(result) - 1])
solution()


(n, t) = map(int, input().split())
kek = tuple(map(int, input().split()))
l = 0
s = 0
res = 0
for r in range(n):
	s += kek[r]
	while s > t:
		s -= kek[l]
		l += 1
	res = max(res, r - l + 1)
print(res)


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
maxbook = 0
pointer1 = 0
currentblock = 0
for i in range(n):
	currentblock += a[i]
	while currentblock > t:
		currentblock -= a[pointer1]
		pointer1 += 1
	maxbook = max(maxbook, i - pointer1 + 1)
print(maxbook)


(n, t) = map(int, input().split())
l = [int(x) for x in input().split()]
ar = [0]
temp = 0
for i in l:
	temp += i
	ar.append(temp)
i = 0
j = 1
m = 0
while j != n + 1:
	if abs(ar[i] - ar[j]) <= t:
		if m < abs(i - j):
			m = abs(i - j)
		j += 1
	else:
		i += 1
		j += 1
print(m)


get_input = lambda : list(map(int, input().split()))
(n, T) = get_input()
arr = get_input()
l = 0
sum = 0
ans = -1
for i in range(n):
	sum += arr[i]
	while sum > T:
		sum -= arr[l]
		l += 1
	ans = max(ans, i - l + 1)
print(ans)


(n, t) = map(int, input().split())
k = list(map(int, input().split()))
x = 0
y = 0
z = 0
u = 0
r = []
while z < n:
	while z < n and x + k[z] <= t:
		y += 1
		x += k[z]
		z += 1
	r.append(y)
	if y:
		x -= k[u]
		u += 1
		y -= 1
	else:
		z += 1
print(max(r))


ino = list(map(int, input().split()))
n = ino[0]
t = ino[1]
summ = 0
k = 0
i = 0
maxx = -1
j = 0
a = list(map(int, input().split()))
while j < n:
	if summ + a[j] <= t:
		summ += a[j]
		j += 1
	else:
		summ -= a[i]
		i += 1
	if j - i > maxx:
		maxx = j - i
print(maxx)


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
start = 0
end = 0
ans = 0
s = 0
l = 0
while end < n:
	s += arr[end]
	l += 1
	if s <= k:
		ans = max(ans, l)
	while start <= end and s > k:
		if s <= k:
			ans = max(ans, l)
		l -= 1
		s -= arr[start]
		start += 1
		if s <= k:
			ans = max(ans, l)
	end += 1
if s <= k:
	ans = max(ans, l)
print(ans)


(n, t) = map(int, input().split())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
b = []
c = [0]
i = 0
count = 0
while i < n:
	if t >= a[i]:
		b.append(a[i])
		t -= a[i]
		count += 1
	elif len(b) > 0:
		c.append(count)
		t += b[0]
		b.pop(0)
		count -= 1
		i -= 1
	i += 1
c.append(count)
print(max(c))


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
s = 0
i = 0
j = 0
k = 0
while j < n:
	if s + c[j] <= m:
		s += c[j]
		j += 1
	else:
		k = max(k, j - i)
		s -= c[i]
		if i == j:
			j += 1
			s += c[i]
		i += 1
k = max(k, j - i)
print(k)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
(tmp, i) = (0, 0)
while tmp + a[i] <= t:
	tmp += a[i]
	i += 1
	if i == len(a):
		print(len(a))
		exit()
ans = cnt = i
for j in range(1, n):
	tmp -= a[j - 1]
	cnt -= 1
	while tmp + a[i] <= t:
		tmp += a[i]
		cnt += 1
		i += 1
		if i == len(a):
			print(max(ans, cnt))
			exit()
	ans = max(ans, cnt)
print(ans)


(n, t) = [int(i) for i in input().split()]
books = [int(i) for i in input().split()]
i = 0
j = 0
count = 0
acum = 0
tmp_acum = 0
tmp_count = 0
while i < n:
	if tmp_acum + books[i] <= t:
		tmp_acum += books[i]
		tmp_count += 1
		i += 1
	else:
		count = max(count, tmp_count)
		tmp_acum = max(tmp_acum - books[j], 0)
		tmp_count = max(tmp_count - 1, 0)
		j += 1
		i = max(i, j)
print(str(max(count, tmp_count)))


(n, t) = map(int, input().split())
minutes = list(map(int, input().split()))
l = 0
sum = 0
count = 0
res = 0
for r in range(n):
	sum += minutes[r]
	count += 1
	while sum > t:
		sum -= minutes[l]
		l += 1
		count -= 1
	res = max(res, count)
print(res)


def check():
	(n, t) = [int(item) for item in input().split()]
	a = [int(item) for item in input().split()]
	start = 0
	end = 0
	total = 0
	while end < n and start < n:
		total += a[end]
		end += 1
		if total > t:
			total -= a[start]
			start += 1
	print(n - start)
check()


first = input('').split()
n = int(first[0])
t = int(first[1])
data = list(map(int, input('').split()))
total = 0
lst = list()
max_len = len(lst) - 1
for i in range(0, n):
	total = total + data[i]
	lst.append(data[i])
	while total > t:
		if len(lst) > max_len:
			max_len = len(lst) - 1
		total = total - lst[0]
		lst.pop(0)
if len(lst) > max_len:
	max_len = len(lst)
print(max_len)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 1000000007
mini = 1000000007

def max_subarray(array):
	max_so_far = max_ending_here = array[0]
	start_index = 0
	end_index = 0
	for i in range(1, len(array) - 1):
		temp_start_index = temp_end_index = None
		if array[i] > max_ending_here + array[i]:
			temp_start_index = temp_end_index = i
			max_ending_here = array[i]
		else:
			temp_end_index = i
			max_ending_here = max_ending_here + array[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			if temp_start_index != None:
				start_index = temp_start_index
			end_index = i
	print(max_so_far, start_index, end_index)

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

def sieve(n):
	prime = [True for i in range(n + 1)]
	lst = []
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p = p + 1
	for i in range(2, n + 1):
		if prime[i]:
			lst.append(i)
	return lst

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			factors.add(n // i)
			n = n // i
			factors.add(i)
	if n > 1:
		factors.add(n)
	return factors

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

def solve(n):
	if n == 1:
		return 1
	p = 2
	result = []
	while p * p <= n:
		if n % p == 0:
			result.append(p)
			result.append(n // p)
		p = p + 1
	return result

def atMostSum(arr, n, k):
	_sum = 0
	cnt = 0
	maxcnt = 0
	for i in range(n):
		if _sum + arr[i] <= k:
			_sum += arr[i]
			cnt += 1
		elif sum != 0:
			_sum = _sum - arr[i - cnt] + arr[i]
		maxcnt = max(cnt, maxcnt)
	return maxcnt

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, t) = get_ints()
Arr = get_array()
print(atMostSum(Arr, n, t))


(n, t) = tuple(map(int, input().split()))
b = list(map(int, input().split()))
j = 0
mx = 0
time = 0
count = 0
for i in range(0, len(b)):
	if time + b[i] <= t:
		time += b[i]
		count += 1
	else:
		mx = max(count, mx)
		time = time - b[j] + b[i]
		j += 1
mx = max(mx, count)
print(mx)


(n, t) = map(int, input().split())
timeForBook = [int(x) for x in input().split()]
countOfBooks = 0
prevBook = 0
sumOfBooks = 0
for i in range(n):
	sumOfBooks += timeForBook[i]
	if sumOfBooks <= t:
		countOfBooks += 1
	else:
		sumOfBooks -= timeForBook[prevBook]
		prevBook += 1
print(countOfBooks)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
r = 0
s = 0
res = 0
for i in range(n):
	if i:
		s -= a[i - 1]
	while r < n and s + a[r] <= t:
		s += a[r]
		r += 1
	res = max(res, r - i)
	r = max(i, r)
print(res)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.setrecursionlimit(int(pow(10, 6)))
	sys.stdin = open('input.txt', 'r')
except:
	pass
(n, t) = L()
A = L()
pref = [0]
for i in range(n):
	pref.append(pref[-1] + A[i])
ans = 0
for i in range(1, n + 1):
	y = bl(pref, pref[i] + t + 1 - A[i - 1])
	ans = max(ans, y - i)
print(ans)
endtime = time.time()


def solve(N, T, A):
	sum = [0, int(A[0])]
	for i in range(1, N):
		sum.append(int(A[i]) + sum[i])
	count = 0
	j = 0
	for i in range(1, N + 1):
		while sum[i] - sum[j] > T:
			j += 1
		count = max(count, i - j)
	return count
num_input = input()
num_input = num_input.split(' ')
N = int(num_input[0])
T = int(num_input[1])
A = input()
A = A.split(' ')
print(solve(N, T, A))


(n, t) = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 0
ind = 0
best = 0
for i in range(n):
	if i >= ind:
		ind = i
		ans = 0
	while ind < n and t >= A[ind]:
		ans += 1
		t -= A[ind]
		ind += 1
	if ans > best:
		best = ans
	if ind == n:
		break
	if ind != i:
		t += A[i]
		ans -= 1
print(best)


(inp1, inp2) = ([int(i) for i in input().split(' ')], [int(i) for i in input().split(' ')])
max = right = result = 0
l = len(inp2)
for i in range(0, l):
	if max < len(inp2):
		while right < l and result + inp2[right] <= inp1[1]:
			result += inp2[right]
			right += 1
		if max < right - i:
			max = right - i
		result -= inp2[i]
	else:
		print(max)
		exit()
print(max)


import sys
f = sys.stdin
(n, t) = map(int, f.readline().split())
a = [int(i) for i in f.readline().strip().split()]
s = 0
res = 0
(left, right) = (0, 0)
while left < n:
	while right < n and s + a[right] <= t:
		s += a[right]
		right += 1
	res = max(res, right - left)
	s -= a[left]
	left += 1
print(res)


import bisect
(n, t) = map(int, input().split())
arr = [0]
for x in input().split():
	arr.append(arr[-1] + int(x))
ans = 0
for x in range(1, n + 1):
	temp = bisect.bisect_right(arr, arr[x - 1] + t) - x
	ans = max(temp, ans)
print(ans)


(n_livros, tempo_livre) = map(int, input().split())
minutos_livro = list(map(int, input().split()))
(i, j, cont, livros_lidos) = (0, 0, 0, 0)
while i < n_livros:
	cont += minutos_livro[i]
	if cont > tempo_livre:
		cont -= minutos_livro[j]
		j += 1
	livros_lidos = i - j + 1
	i += 1
print(livros_lidos)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
l = 0
r = 0
summ = a[0]
a.append(0)
while r < n:
	if t >= summ:
		if r - l + 1 > count:
			count = r - l + 1
		summ += a[r + 1]
		r += 1
	else:
		summ -= a[l]
		l += 1
print(count)


(a, b) = map(int, input().split())
books = list(map(int, input().split()))
tot = 0
p = 0
counter = 0
for i in range(a):
	tot += books[i]
	while b < tot:
		tot -= books[counter]
		counter += 1
	p = max(p, i - counter + 1)
print(p)


(n, t) = map(int, input().split())
c = list(map(int, input().split()))
(u, s, z) = (0, 0, 0)
for v in range(n):
	s += c[v]
	while s > t:
		s -= c[u]
		u += 1
	z = max(z, v - u + 1)
print(z)


from sys import stdin, stdout
from math import gcd
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, t) = iia()
arr = iia()
p1 = cur = res = 0
for i in range(n):
	cur += arr[i]
	if cur > t:
		res = max(res, i - p1)
		cur -= arr[p1]
		p1 += 1
res = max(res, i - p1 + 1)
print(res)


(n, k) = map(int, input().split())
t = [0] + list(map(int, input().split())) + [k + 1]
for i in range(2, len(t)):
	t[i] += t[i - 1]
(i, j, s) = (0, 1, 0)
n += 2
while j < n:
	while j < n and t[j] <= k + t[i]:
		j += 1
	i += 1
	s = max(s, j - i)
print(s)


def sumtill(i, j):
	global sumo
	if i == 0:
		return sumi[j]
	return sumi[j] - sumi[i - 1]

def binary_search(arr, left, right, i):
	if left > right:
		return -1
	mid = (left + right) // 2
	if sumtill(i, mid) <= t:
		if mid == right:
			return right
		if sumtill(i, mid + 1) > t:
			return mid
		return binary_search(arr, mid + 1, right, i)
	else:
		return binary_search(arr, left, mid - 1, i)
l = input().split()
n = int(l[0])
t = int(l[1])
l = input().split()
li = [int(i) for i in l]
sumi = [0 for i in range(n)]
sumo = 0
for i in range(n):
	sumo += li[i]
	sumi[i] = sumo
ans = 0
for i in range(n):
	j = binary_search(li, i, n - 1, i)
	ans = max(ans, j - i + 1)
print(ans)


def book_():
	(n, t) = map(int, input().split())
	l = []
	l = [int(num) for num in input().split()]
	m = len(l)
	max = 0
	sum = 0
	c = 0
	i = 0
	while i < len(l) and len(l) > 0:
		sum = sum + l[i]
		if sum <= t:
			c = c + 1
			i = i + 1
			if max <= c:
				max = c
		else:
			sum = sum - l[0]
			l.pop(0)
	print(max)
book_()


(n, M) = map(int, input().split())
a = list(map(int, input().split()))
j = 0
m = 0
sum1 = 0
count = 0
for i in range(n):
	sum1 = sum1 + a[i]
	count += 1
	while sum1 >= M:
		if sum1 == M:
			count = count
			m = max(count, m)
			sum1 = sum1 - a[j]
			count = count - 1
		else:
			count = count - 1
			m = max(m, count)
			sum1 = sum1 - a[j]
		j = j + 1
m = max(m, count)
print(m)


from sys import stdin

def libros(n, t, libros):
	con = 0
	a = 0
	men = 0
	may = 0
	while men < n:
		while may < n and con + libros[may] <= t:
			con += libros[may]
			may += 1
		b = may - men
		if b > a:
			a = b
		con -= libros[men]
		men += 1
	return a

def main():
	(n, t) = stdin.readline().strip().split()
	n = int(n)
	t = int(t)
	tlibros = [int(x) for x in stdin.readline().strip().split()]
	z = libros(n, t, tlibros)
	print(z)
main()


(n, t) = map(int, input().split())
B = [int(i) for i in input().split()]
(i, j, sum, res) = (0, 0, B[0], 0)
while j < len(B) - 1 and i < len(B):
	if sum <= t:
		res = max(res, j - i + 1)
		j = j + 1
		sum = sum + B[j]
	else:
		sum = sum - B[i]
		i = i + 1
if sum <= t:
	res = max(res, j - i + 1)
print(res)


def fun(t, nums):
	le = len(nums)
	l = 0
	r = 1
	if le == 1:
		if t < nums[0]:
			return 0
		else:
			return 1
	sum = 0
	books = 0
	k = 0
	for i in range(le):
		sum += nums[i]
		if sum <= t:
			books += 1
		else:
			sum -= nums[k]
			k += 1
	return books
(var1, var2) = [int(x) for x in input().split()]
user_input = input().split(' ')
numbers = [int(x.strip()) for x in user_input]
print(fun(var2, numbers))


(n, k) = input().split()
n = int(n)
k = int(k)
a = [int(x) for x in input().split()]
l = 0
r = 0
s = 0
m = 0
for i in range(n):
	while s <= k:
		m = max(r - i, m)
		if r == n:
			break
		s += a[r]
		r += 1
	s -= a[i]
print(m)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, t) = f()
l = il()
i = 0
j = 0
sm = 0
mx = 0
while i < n and j < n:
	if sm + l[j] <= t:
		sm += l[j]
		j += 1
		mx = max(mx, j - i)
	else:
		sm -= l[i]
		i += 1
print(mx)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
j = 0
maxx = 0
summ = 0
while j <= n:
	if j == n:
		maxx = max(maxx, j - 1 - i + 1)
		break
	if summ + a[j] > t:
		maxx = max(maxx, j - 1 - i + 1)
		i += 1
		summ -= a[i - 1]
	else:
		summ += a[j]
		j += 1
print(maxx)


from sys import stdin, stdout
import sys
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))
(n, t) = mp()
a = mp()
x = 0
count = counti = 0
summ = 0
for i in range(n):
	if summ + a[i] <= t:
		summ += a[i]
		counti += 1
	else:
		count = max(count, counti)
		summ += a[i] - a[x]
		x += 1
		counti = i - x + 1
count = max(count, counti)
cout(str(count))


(n, x) = map(int, input().split())
a = map(int, input().split())
b = []
for i in a:
	b.append(i)
h = 0
t = 0
c = 0
l = 0
ml = 0
for i in range(n):
	c = c + b[i]
	h = h + 1
	l = l + 1
	if c > x:
		l = l - 1
		c = c - b[t]
		t = t + 1
	if ml < l:
		ml = l
print(ml)


from sys import stdin, stdout
from collections import Counter
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
(n, t) = ei()
time = ai()
i = j = 0
ans = 0
count = 0
final = []
while i < n and j < n:
	if ans + time[j] <= t:
		ans += time[j]
		count += 1
		j += 1
	else:
		ans -= time[i]
		i += 1
		final.append(count)
		count -= 1
final.append(count)
try:
	print(max(final))
except:
	print(0)


import sys

def binary(arraySum, n, value):
	(low, high) = (0, n)
	while low <= high:
		mid = (low + high) // 2
		if arraySum[mid] == value:
			return mid
		elif arraySum[mid] > value:
			high = mid - 1
		else:
			low = mid + 1
	return high

def main():
	(n, t) = [int(x) for x in sys.stdin.readline().strip().split()]
	lista = [int(x) for x in sys.stdin.readline().strip().split()]
	arraySum = [lista[0]]
	for i in range(1, n):
		arraySum.append(arraySum[i - 1] + lista[i])
	arraySum.insert(0, 0)
	books = 0
	for i in range(n):
		j = binary(arraySum, n, t + arraySum[i])
		books = max(books, j - i)
	print(books)
main()


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
j = 0
curr = 0
ans = 0
count = 0
cur_count = 0
for i in range(n):
	if A[i] + curr <= t:
		cur_count += 1
		curr += A[i]
	else:
		curr = curr - A[j] + A[i]
		j += 1
	count = max(count, cur_count)
print(count)


def main():
	nk = list(map(int, input('').split()))
	aList = list(map(int, input('').split()))
	n = nk[0]
	k = nk[1]
	sum = 0
	count = 0
	j = 0
	result = 0
	for i in range(0, len(aList)):
		sum = sum + aList[i]
		while sum > k:
			sum = sum - aList[j]
			count -= 1
			j += 1
		result = max(result, i - j + 1)
	print(result)
main()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
prefix_sum = [0]
for i in range(n):
	prefix_sum.append(prefix_sum[i] + a[i])
(x, y) = (0, 1)
ans = 0
n += 1
while y < n:
	if prefix_sum[y] - prefix_sum[x] <= t:
		if ans < y - x:
			ans = y - x
		y += 1
	else:
		x += 1
print(ans)


(x, t) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
b = []
j = mx = 0
for i in range(0, x):
	s += a[i]
	b.append(a[i])
	j += 1
	if s > t:
		mx = max(mx, j - 1)
		while s > t:
			s -= b[0]
			del b[0]
			j -= 1
print(max(mx, j))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 5
T = 1
for _ in range(T):
	(n, t) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	p = [0] * (n + 1)
	for i in range(1, n + 1):
		p[i] = p[i - 1] + a[i - 1]
	ans = 0
	for i in range(1, n + 1):
		ix = bisect_right(p, p[i - 1] + t)
		ans = max(ans, ix - i)
	print(ans)


import os
import sys
from io import BytesIO, IOBase
from itertools import accumulate

def solution(arr, n, t):
	(sums, j) = (0, 0)
	res = 0
	for i in range(n):
		while j < n and sums + arr[j] <= t:
			sums += arr[j]
			j += 1
		res = max(res, j - i)
		sums -= arr[i]
	write(res)

def main():
	(n, t) = r_array()
	arr = r_array()
	solution(arr, n, t)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, sep=' ', end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + sep)
	sys.stdout.write(str(args[-1]) + end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import sys

class Solution:

	def max_books_read(self, free_time, books_time):
		j = r = 0
		for (i, _) in enumerate(books_time):
			while j < len(books_time) and free_time >= books_time[j]:
				free_time -= books_time[j]
				j += 1
			free_time += books_time[i]
			r = max(r, j - i)
		return r

def main():
	inp = sys.stdin.readline()
	(_, free_time) = list(map(int, inp.split()))
	inp = sys.stdin.readline()
	books_time = list(map(int, inp.split()))
	print(Solution().max_books_read(free_time, books_time))
main()


(n, t) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
left = 0
right = 0
acc = 0
l = 0
for i in range(n):
	right = i
	acc += arr[i]
	if acc > t:
		l = max(l, right - left)
		acc -= arr[left]
		left += 1
l = max(l, right + 1 - left)
print(l)


(n, t) = map(int, input().split())
book = list(map(int, input().split()))
L = 0
R = 0
count = 0
sum = 0
for R in range(n):
	sum += book[R]
	count += 1
	if sum > t:
		sum -= book[L]
		count -= 1
		L += 1
print(count)


import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
(n, t) = sp()
arr = l()
temp = t
(answer, res) = (0, 0)
index = None
for i in range(n):
	if arr[i] <= t:
		index = i
		break
if index is None:
	out('0')
	exit()
j = index
for i in range(j, n):
	if arr[i] > t:
		if i == n - 1:
			break
		index = i + 1
		answer = max(res, answer)
		res = 0
		temp = t
		continue
	if arr[i] > temp:
		temp += arr[index]
		index += 1
		answer = max(answer, res)
		res -= 1
	temp -= arr[i]
	res += 1
	answer = max(answer, res)
out(str(answer))


def ans(b, n, t):
	if sum(b) <= t:
		return n
	i = 0
	ans = 0
	while i < n and b[i] > t:
		i += 1
	if i < n:
		ans = 1
		t -= b[i]
	j = i + 1
	while j < n:
		if b[j] <= t:
			tmp = j - i + 1
			if tmp > ans:
				ans = tmp
			t -= b[j]
			j += 1
		else:
			while b[j] > t and i < j:
				t += b[i]
				i += 1
			if i == j:
				while i < n and b[i] > t:
					i += 1
				if i < n:
					t -= b[i]
				j = i + 1
	return ans
(n, t) = map(int, input().split())
books = [int(i) for i in input().split()]
print(ans(books, n, t))


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
p = p = p = p = 0
m = 0
l = [0]
while m <= t and p < n and (t - m >= a[p]):
	m += a[p]
	p += 1
l.append(p)
g = 0
while p < n and g < n:
	m -= a[g]
	g += 1
	if g == p:
		while g < n and a[g] > t:
			g = p + 1
			p = g
	while m <= t and p < n and (t - m >= a[p]) and (g < n):
		m += a[p]
		p += 1
	l.append(p - g + 1 - 20 + 19)
print(max(l))


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
s = 0
c = 0
mc = 0
i = 0
for j in range(0, n):
	s = s + l[j]
	c = c + 1
	while s > t:
		s = s - l[i]
		i = i + 1
		c = c - 1
	if c > mc:
		mc = c
print(mc)


(n_books, n_time_reading) = list(map(int, input().split()))
minutes = list(map(int, input().split()))

def get_max_with_o_n_2():
	my_max = 0
	for i in range(n_books):
		total = 0
		count = 0
		for j in range(i, n_books):
			total += minutes[j]
			if total <= n_time_reading:
				count += 1
			else:
				break
		if count == n_books:
			return n_books
		if count >= my_max:
			my_max = count
	return my_max

def get_the_first_array(n_books, n_time_reading, minutes):
	first_count = 0
	first_value = 0
	for i in range(n_books):
		first_value += minutes[i]
		if first_value <= n_time_reading:
			first_count += 1
		else:
			return [i - 1, first_count, first_value - minutes[i]]
	return [n_books, first_count, first_value]

def get_max_with_o_n(n_books, n_time_reading, minutes):
	if n_books == 1:
		if minutes[0] <= n_time_reading:
			return 1
		else:
			return 0
	(j, first_count, first_value) = get_the_first_array(n_books, n_time_reading, minutes)
	my_max = first_count
	if my_max == n_time_reading:
		return my_max
	for i in range(1, n_books):
		first_value -= minutes[i - 1]
		first_count -= 1
		j += 1
		while j <= n_books - 1:
			first_value += minutes[j]
			if first_value <= n_time_reading:
				j += 1
				first_count += 1
			else:
				first_value -= minutes[j]
				j -= 1
				break
		if first_count > my_max:
			my_max = first_count
	return my_max
print(get_max_with_o_n(n_books, n_time_reading, minutes))


(n, t) = map(int, input().split())
ai = list(map(int, input().split()))
ans = 0
ind1 = 0
ind2 = -1
num = 0
while ind2 < n:
	if num <= t:
		ans = max(ans, ind2 - ind1 + 1)
		ind2 += 1
		if ind2 < n:
			num += ai[ind2]
	else:
		num -= ai[ind1]
		ind1 += 1
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
san = 0
i = -1
t = 0
s = 0
c = 0
while i < n - 1:
	i += 1
	for j in range(s, n):
		if t + a[j] > m:
			break
		else:
			t += a[j]
			c += 1
	if c >= san:
		san = c
	t -= a[i]
	c -= 1
	s = j
print(san)


nt = input().split()
(n, t) = (int(x) for x in nt)
line = input().split()
times = [int(x) for x in line]
total_time = 0
counter = 0
max_counter = 0
read_books = []
for time in times:
	if total_time + time <= t:
		total_time += time
		read_books.append(time)
		counter += 1
		if counter > max_counter:
			max_counter = counter
	elif read_books != []:
		old_time = read_books.pop(0)
		read_books.append(time)
		total_time = total_time - old_time + time
print(counter)


(n, t) = map(int, input().split())
ls = list(map(int, input().split()))
total_time = 0
i = 0
j = 0
count = 0
while i < n and j <= i:
	total_time += ls[i]
	count += 1
	i += 1
	if total_time > t:
		total_time -= ls[j]
		j += 1
		count -= 1
print(count)


(n, t) = map(int, input().split())
data = [int(i) for i in input().split()]
sums = [0]
for i in range(n):
	sums.append(sums[-1] + data[i])
(i, j) = (1, 1)
ans = 0
while j <= n and i <= n:
	while i <= n and j <= n and (sums[j] - sums[i - 1] <= t):
		j += 1
	ans = max(ans, j - i)
	i += 1
print(ans)


nt = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
i = 0
mb = 0
t = nt[1]
while i < nt[0] and a[i] <= t:
	mb += 1
	t -= a[i]
	i += 1
books = mb
for j in range(1, nt[0]):
	books -= 1
	t += a[j - 1]
	while i < nt[0] and a[i] <= t:
		books += 1
		t -= a[i]
		i += 1
	mb = max(mb, books)
print(mb)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = r = 0
temp = a[0]
ans = 0
while r < len(a):
	if temp <= m:
		ans = max(ans, r - l + 1)
		r += 1
		if r < len(a):
			temp += a[r]
	else:
		temp -= a[l]
		l += 1
		if l > r:
			r = l
			if r < len(a):
				temp = a[l]
print(ans)


(n, m) = map(int, input().split())
l = [int(s) for s in input().split()]
i = j = 0
ans = sum1 = 0
while i < n:
	sum1 += l[i]
	if sum1 > m:
		sum1 -= l[j]
		j += 1
	i += 1
print(n - j)


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
res = 0
i = 0
j = 0
ts = 0
while i < n:
	if a[i] > t:
		i += 1
		continue
	if ts == 0:
		ts += a[i]
		res = max(1, res)
		j = i + 1
	while j < n and ts + a[j] <= t:
		ts += a[j]
		j += 1
	res = max(j - i, res)
	if j == n:
		break
	ts -= a[i]
	i += 1
print(res)


(n, t) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
total_time = 0
count = 0
j = 0
for i in range(n):
	while j < n and total_time + a[j] <= t:
		total_time += a[j]
		j += 1
	count = max(count, j - i)
	total_time -= a[i]
	if j == n - 1:
		print(count)
		exit()
print(count)


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
(k, res, j) = (0, 0, 0)
for i in range(0, n):
	res += a[i]
	while res > m:
		res -= a[j]
		j += 1
	if k < i - j + 1:
		k = i - j + 1
print(k)


import sys
(n, t) = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
s = 0
if min(a) > t:
	l = 0
else:
	l = 1
	tmp_s = 0
	for i in range(n):
		if i > 0:
			tmp_s -= a[i - 1]
		tmp_s += a[i + l - 1]
		for j in range(i + l, n):
			if tmp_s + a[j] > t:
				l = max(l, j - i)
				break
			tmp_s += a[j]
		else:
			l = max(l, n - i)
			break
print(l)


(n, t) = map(int, input().split())
time = list(map(int, input().split()))
max_books = 0
counter = 0
clock = 0
for i in range(n):
	clock += time[i]
	if clock > t:
		clock -= time[counter]
		counter += 1
	max_books = max(max_books, i + 1 - counter)
print(max_books)


(n, t) = map(int, input().split())
li = list(map(int, input().split()))
st = 0
count = 0
for i in range(n):
	st += li[i]
	if st > t:
		st -= li[count]
		count += 1
print(n - count)


(n, t) = [int(x) for x in input().split()]
times = [int(x) for x in input().split()]
books = []
for i in range(n):
	books.append(0)
currentTime = 0
if times[n - 1] <= t:
	currentTime += times[n - 1]
	books[n - 1] += 1
for i in range(n - 2, -1, -1):
	if currentTime + times[i] <= t:
		currentTime += times[i]
		books[i] = books[i + 1] + 1
	else:
		j = books[i + 1]
		while j > 0:
			currentTime -= times[i + j]
			if currentTime + times[i] <= t:
				currentTime += times[i]
				break
			j -= 1
		books[i] = j
print(max(books))


(n, t) = map(int, input().split())
ls = list(map(int, input().split()))
max = 0
count = 0
sum = 0
i = 0
j = 0
while j < n:
	sum = sum + ls[j]
	count += 1
	j += 1
	if sum > t:
		i += 1
		count -= 1
		sum = sum - ls[i - 1]
	if max < count:
		max = count
print(max)


def binSearch(arr, left, right, el):
	while left < right:
		mid = (left + right) // 2
		if arr[mid] == el:
			return mid
		if arr[mid] > el:
			right = mid - 1
		else:
			left = mid + 1
	if arr[left] == el:
		return left
	if arr[left] > el:
		return left - 1
	return left

def solve(arr, n, t):
	res = 0
	dpArr = [arr[0]] * n
	for i in range(1, n):
		dpArr[i] = arr[i] + dpArr[i - 1]
	for i in range(n):
		if i == 0:
			el = t
		else:
			el = t + dpArr[i - 1]
		j = binSearch(dpArr, i, n - 1, el)
		res = max(res, j - i + 1)
	return res
(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
print(solve(arr, n, t))


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(l, ps, n, t):
	for i in range(n - l + 1):
		if ps[i + l] - ps[i] <= t:
			return True
	return False
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	(n, t) = read()
	a = list(read())
	ps = [0]
	for x in a:
		ps.append(ps[-1] + x)
	low = 1
	high = n
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, ps, n, t):
			low = mid + 1
		else:
			high = mid
	if check(low, ps, n, t):
		print(low)
	else:
		print(low - 1)
for _ in range(1):
	solve()


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
s = 0
mb = 0
c = 0
for (i, e) in enumerate(a):
	if s + e <= m:
		s += e
		c += 1
	else:
		mb = max(mb, c)
		while s + e > m:
			s -= a[i - c]
			c -= 1
		c += 1
		s += e
mb = max(mb, c)
print(mb)


(n, t) = map(int, input().split())
lst = list(map(int, input().split()))
l = 0
s = 0
mx = 0
for r in range(len(lst) + 1):
	if s > t:
		s -= lst[l]
		l += 1
	else:
		mx = max(mx, r - l)
	if r < len(lst):
		s += lst[r]
print(mx)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(i, j, res, s) = (0, 0, 0, a[0])
while j < len(a):
	if s <= t:
		res = max(res, j - i + 1)
		j += 1
		if j < len(a):
			s += a[j]
		continue
	if s > t:
		s -= a[i]
		i += 1
	if i > j:
		j += 1
		if j < len(a):
			s += a[j]
print(res)


3
(n, t) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
s = 0
ans = 0
i = 0
for j in range(n):
	s += a[j]
	while s > t:
		s -= a[i]
		i += 1
	ans = max(ans, j - i + 1)
print(ans)


t = input()
temp = t.split()
n = int(temp[0])
t = int(temp[1])
s = input()
temp = s.split()
books = [int(i) for i in temp]
count = 0
time = 0
j = 0
for i in range(len(books)):
	time = time + books[i]
	if time <= t:
		count += 1
	else:
		time = time - books[j]
		j += 1
print(count)


(n, t) = map(int, input().split())
times = list(map(int, input().split()))
start = -1
for i in range(len(times)):
	if times[i] <= t:
		start = i
		break
if start == -1:
	print(0)
	exit()
start_i = start
end_i = start
cur = 1
max = 1
time_holder = times[start]
end_i += 1
while end_i < n:
	next_time = times[end_i]
	if time_holder + next_time <= t:
		time_holder += next_time
		cur += 1
		if cur > max:
			max = cur
		end_i += 1
	else:
		time_holder -= times[start_i]
		cur -= 1
		start_i += 1
print(max)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
l = 0
r = 0
cnt = 0
sum = 0
while r < n:
	sum += arr[r]
	if sum <= t:
		cnt += 1
	else:
		sum -= arr[l]
		l += 1
	r += 1
print(cnt)


import sys
n = 0
t = 0
A = []

def readInput():
	global n
	global t
	global A
	i = 1
	for line in sys.stdin:
		_d = line.split(' ')
		if i == 1:
			n = int(_d[0])
			t = int(_d[1])
		if i == 2:
			for x in _d:
				A.append(int(x))
		i += 1

def mockInput():
	global n
	global t
	global A
	n = 4
	t = 5
	A = [3, 1, 2, 1]

def solve():
	global n
	global t
	global A
	l = 0
	s = 0
	for j in range(0, n):
		if s + A[j] > t:
			break
		else:
			s += A[j]
			l += 1
	max_len = l
	for i in range(0, n):
		s -= A[i]
		l -= 1
		for j in range(i + l + 1, n):
			if s + A[j] > t:
				break
			else:
				s += A[j]
				l += 1
		if l > max_len:
			max_len = l
	return max_len
readInput()
print(solve())


(number_of_books, times) = map(int, input().split())
time_of_each_book = list(map(int, input().split()))
total_reading_time = 0
answer = 0
left = 0
for index in range(number_of_books):
	total_reading_time += time_of_each_book[index]
	while total_reading_time > times:
		total_reading_time -= time_of_each_book[left]
		left += 1
	answer = max(answer, index - left + 1)
print(answer)


(n, time) = map(int, input().split())
books = [int(x) for x in input().split()]
current_sum = 0
answer = 0
start = 0
for i in range(n):
	current_sum += books[i]
	if current_sum > time:
		answer = max(i - start, answer)
		current_sum -= books[start]
		start += 1
if current_sum <= time:
	answer = max(answer, n - start)
print(answer)


(n, t) = map(int, input().split())
count = 0
l = list(map(int, input().split()))
(p, k, s) = (0, 0, 0)
for i in range(n):
	s += l[i]
	if s > t:
		s -= l[k]
		k += 1
print(n - k)


(n, k) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
j = 0
sum = 0
res = 0
for i in range(n):
	sum += a[i]
	while j <= i and sum > k:
		sum -= a[j]
		j += 1
	res = max(res, i - j + 1)
print(res)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
k = 0
su = 0
for i in range(n):
	if su + a[i] <= t:
		su += a[i]
		k += 1
	else:
		break
for i in range(n):
	try:
		su -= a[i]
		su += a[k + i]
		if su + a[i + k + 1] <= t:
			r = k
			for j in range(r + i + 1, n):
				if su + a[j] <= t:
					su += a[j]
					k += 1
				else:
					break
	except:
		break
print(k)


(n, t) = map(int, input().split())
a = [0] + [int(i) for i in input().split()]
cs = 0
pref_sums = []
for i in a:
	cs += i
	pref_sums.append(cs)
ans = 0
for i in range(1, n + 1):
	l = i - 1
	r = n + 1
	while r - l > 1:
		m = l + (r - l) // 2
		diff = pref_sums[m] - pref_sums[i - 1]
		if diff <= t:
			l = m
		else:
			r = m
	ans = max(ans, l - i + 1)
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
mx = 0
partialsum = [0] * n
partialsum[0] = a[0]
for i in range(1, n):
	partialsum[i] += partialsum[i - 1] + a[i]
for i in range(n):
	s = i
	e = n - 1
	while s != e:
		g = (s + e + 1) // 2
		if i > 0:
			ps = partialsum[g] - partialsum[i - 1]
		else:
			ps = partialsum[g]
		if ps > t:
			e = g - 1
		else:
			s = g
	mx = max(mx, s - i + 1)
if t < min(a):
	mx = 0
print(mx)


(n, t) = map(int, input().split())
a = [0]
a += list(map(int, input().split()))
for i in range(1, n + 1):
	a[i] += a[i - 1]
l = 0
lb = 0
rb = 0
nb = 0
for r in range(1, n + 1):
	while a[r] - a[l] > t:
		l += 1
	if r - l > nb:
		rb = r
		lb = l
		nb = r - l
print(nb)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
s = 0
mx = 0
i = 0
r = 0
while r < n:
	while r < n and s + l[r] <= t:
		s += l[r]
		r += 1
	mx = max(mx, r - i)
	s -= l[i]
	i += 1
	if i >= n:
		break
print(mx)


(n, t) = map(int, input().split())
books = [int(i) for i in input().split()]
back = 0
front = 0
ans = 0
tmp = 0
while front < n:
	if tmp + books[front] <= t:
		tmp += books[front]
		front += 1
	else:
		tmp += books[front]
		if front - back > ans:
			ans = front - back
		while tmp > t:
			tmp -= books[back]
			back += 1
		front += 1
if front - back > ans:
	ans = front - back
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
start = end = temp = ans = curmax = 0
while end < n:
	if temp + a[end] <= t:
		temp += a[end]
		end += 1
	else:
		curmax = end - start
		if curmax > ans:
			ans = curmax
		temp -= a[start]
		curmax -= 1
		start += 1
ans = max(ans, end - start)
print(ans)


import math
import sys

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(length, time) = map(int, input().split())
books = inlt()
i = 0
j = 0
count = 0
temp = 0
maxi = 0
while j < length and i < length:
	if count + books[j] <= time:
		count += books[j]
		j += 1
		temp += 1
	else:
		while count + books[j] > time:
			count -= books[i]
			i += 1
			temp -= 1
	maxi = max(maxi, temp)
print(maxi)


n = input().split(' ')
t = int(n[1])
n = int(n[0])
if t != 0:
	book = input().split(' ')
book = list(map(int, book))
ans = 0
sum = 0
left = 0
for right in range(0, n):
	sum += book[right]
	while sum > t:
		sum -= book[left]
		left = left + 1
	ans = max(ans, right - left + 1)
print(ans)


def ans(a_list, k):
	length = len(a_list)
	l_length = 0
	longest = 0
	s = 0
	for i in range(length):
		while s <= k:
			longest = max(l_length, longest)
			if i + l_length == length:
				return longest
			s += a_list[i + l_length]
			l_length += 1
		l_length -= 1
		s -= a_list[i]
	return longest
(a, m) = map(int, input().split())
arr = list(map(int, input().split()))
print(ans(arr, m))


def solution(m, books):
	answer = 0
	n = len(books)
	left = 0
	while left < n and books[left] > m:
		left += 1
	if left == n:
		return 0
	right = left
	now = books[left]
	cnt = right - left + 1
	answer = cnt
	while left < n and right < n:
		while right + 1 < n and books[right + 1] + now <= m:
			now += books[right + 1]
			right += 1
		answer = max(right - left + 1, answer)
		now -= books[left]
		left += 1
		if left == n:
			break
		if left > right:
			right = left
			now += books[left]
	return answer
(n, m) = map(int, input().split())
books = list(map(int, input().split()))
print(solution(m, books))


(n, t) = map(int, input().split())
books = list(map(int, input().split()))
acc = 0
max_read = 0
cur_read = 0
offset = 0
i = 0
while i < n:
	if acc + books[i] <= t:
		acc += books[i]
		cur_read += 1
		max_read = max(max_read, cur_read)
		i += 1
	else:
		acc = max(0, acc - books[offset])
		offset += 1
		i = max(i, offset)
		cur_read = max(0, cur_read - 1)
print(max_read)


(n, t) = map(int, input().split())
mins = list(map(int, input().split()))
time = 0
maxBooks = 0
(left, right) = (0, 0)
while left < n:
	while right < n and time + mins[right] <= t:
		time += mins[right]
		right += 1
	maxBooks = max(maxBooks, right - left)
	time -= mins[left]
	left += 1
print(maxBooks)


def main():
	from sys import stdin, stdout
	(n, t) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	maxim = 0
	curr_sum = arr[0]
	i = 0
	j = 1
	if curr_sum <= t:
		count = 1
	else:
		curr_sum = 0
		count = 0
		i = 1
		j = 2
	while j < n:
		if curr_sum + arr[j] <= t:
			count += 1
			curr_sum += arr[j]
			j += 1
		else:
			maxim = max(count, maxim)
			if curr_sum:
				curr_sum -= arr[i]
				count -= 1
			else:
				j += 1
			i += 1
	maxim = max(count, maxim)
	stdout.write(str(maxim))
main()


a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 0
ans = 0
s = 0
for i in range(a[0]):
	s += b[i]
	while s > a[1]:
		s -= b[l]
		l += 1
	ans = max(ans, i - l + 1)
print(ans)


g = input()
(n, t) = [int(x) for x in g.split()]
r = input()
li = []
if n > 1:
	for y in r.split():
		li.append(int(y))
else:
	li.append(int(r))
lis = []
flag = 0
tt = 0
l = 0
d = 0
j = 0
for i in range(n):
	l += 1
	d += li[i]
	if d > t:
		if l == 1:
			flag = 1
			tt = 0
			break
		else:
			break
	j = i
	tt += 1
if flag == 0:
	lis.append(tt)
else:
	lis.append(0)
if j == n - 1:
	print(tt)
else:
	hjk = j + 2
	if j == 0 and flag == 1:
		hjk = j + 1
	ilk = 0
	while hjk < n:
		d += li[hjk] - li[ilk]
		ilk += 1
		if d <= t:
			tt += 1
			if hjk == n - 1:
				break
			for g in range(hjk + 1, n):
				d += li[g]
				if d > t:
					break
				else:
					tt += 1
			hjk = g + 1
		else:
			hjk += 1
	print(tt)