program tickets;
const maxn=1000000;
var
a:array [1..maxn] of longint;
n,f,max,head,tail,total:longint;
f1,f2:text;
procedure init;
var i:longint;
begin
assign(f1,'tickets.in'); reset(f1);
assign(f2,'tickets.out'); rewrite(f2);
readln(f1,n,f);
for i:=1 to n do
read(f1,a[i]);
close(f1);
head:=1;
tail:=1;
total:=0;
max:=0;
end;
procedure play;
begin
while tail<=n do begin
while (tail<=n)and(total+a[tail]<=f) do begin
total:=total+a[tail];
tail:=tail+1;
end;
if head=tail then begin
head:=head+1;
tail:=tail+1;
end
else begin
tail:=tail-1;
if tail-head+1>max then max:=tail-head+1;
total:=total-a[head];
head:=head+1;
tail:=tail+1;
end;
end;
end;
procedure print;
begin
writeln(f2,max);
close(f2);
end;
begin
init;
play;
print;
end.