{买票}
{水题}
{yangbohua}
{time: 2010-10-25}
program tickets;
var
a:array[0..1000010] of longint;
h,t,n,m,i,s,ans:longint;
begin
assign(input,'tickets.in');
reset(input);
assign(output,'tickets.out');
rewrite(output);
readln(n,m);
for i:=1 to n do
read(a[i]);
h:=0;
t:=0;
if a[1]<=m then
begin
t:=1;
s:=a[1];
end;
ans:=0;
while t<n do
begin
while (s+a[t+1]<=m) and (t+1<=n) do
begin
s:=s+a[t+1];
t:=t+1;
end;
if t-h>ans
then ans:=t-h;
if h<t then
begin
s:=s-a[h+1];
h:=h+1;
end
else
begin
h:=h+1;
t:=t+1;
end;
end;
writeln(ans);
close(input);
close(output);
end.