program tickets;
var
data:array [1..1000001] of longint;
flag:boolean;
i,ans,n,f,head,tail,max:longint;
begin
assign (input,'tickets.in');
reset (input);
readln (n,f);
for i:=1 to n do read (data[i]);
close (input);
assign (output,'tickets.out');
rewrite (output);
flag:=false;
for i:=1 to n do if f>=data[i] then begin
flag:=true;
break;
end;
if flag=false then begin
writeln (0);
close (output);
halt;
end;
head:=1;tail:=1;ans:=0;max:=0;
while tail<>n+1 do begin
while (f>=data[tail]) and (tail<=n) do begin
f:=f-data[tail];
inc(tail);
inc(ans);
end;
if ans>max then max:=ans;
while not((head>=tail) or (f>=data[tail])) do begin
f:=f+data[head];
inc(head);
dec(ans);
end;
if head>tail then head:=tail;
end;
writeln (max);
close (output);
end.