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

Difficulty: interview

Starter code:

Solutions:

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)
##    elif segSum > time:
##        segments.append(r-l)
##        while segSum > time or l < r:
##            # Shifting l to the right
##            # until reaching next suitable segment sum
##            segSum -= a[l]
##            l += 1
##        #segments.append(r+1-l)
##
##[1,2,5,3,7,4,5]

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))


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)


import sys
f = sys.stdin
# f = open("input.txt", "r")
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)

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, 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 read_books(start_index, time, books):
    remaining = time
    current_index = start_index
    books_read = 0
    while True:
        # If we ran out of books
        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)
    
    # Compute if we started with the first book
    nbooks[0] = read_books(0, time, books)

    # compute if we start from the next index
    for i in range(1, len(books)):
        # read what you read previously without the previous book
        min_books = nbooks[i-1][0] - 1
        max_remaining = nbooks[i-1][1] + books[i-1]
        
        # Try to read some more
        extra = read_books(nbooks[i-1][2], max_remaining, books)

        # compute the total
        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=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)
    


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

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)
        return
print(max)

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)


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))


def __starting_point():
    main()
__starting_point()

def main():
    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)


def __starting_point():
    main()
__starting_point()

# coding: utf-8
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)


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

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)

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)

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)

# Время прохода - 2n


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]
    
#     print(str(start_idx) + ' ' + str(end_idx))
    
    if t + current_time > mins:
        
        #Keep bumping start pointer till we fit  
        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
    
#     print(str(start_idx) + ' ' + str(end_idx))
#     print(str(current_max + 1) + ' current time:' + str(current_time) ) 
#     print(' ')   

current_max = end_idx - start_idx if end_idx - start_idx > current_max else current_max

print(current_max + 1)            
            
        


__author__ = "runekri3"

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

max_books = 0
max_books_changed = 0
# last_time = 0
min_time = 0
for i in range(n):
    first_book_time = times[i]
    # last_book_time = times[i+max_books]
    try:
        min_time += times[i + max_books]
    except IndexError:
        break
    # if max_books_changed:
    #     min_time += sum(times[i + max_books - max_books_changed:i + max_books + 1])
    # else:
    #     min_time += times[i + max_books]
    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  # Check if max_books can be increased more
    min_time -= first_book_time

print(max_books)




n,t=list(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)     

    


n, t = list(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)


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 = list(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())
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)