from collections import defaultdict,deque n,w=map(int,input().split()) d=defaultdict(int) ans=0 now=0 q=deque() for _ in range(n): a=int(input()) now+=a q.append(a) d[a]+=1 while (d[a]>1 or now>w) and q: out=q.popleft() now-=out d[out]-=1 ans=max(ans,len(q)) print(ans)