var
n,k,i,ans,now,max,min,j:longint;
a:Array[0..100000]of longint;
begin
assign(input,'riverbed.in'); reset(input);
assign(output,'riverbed.out'); rewrite(output);
readln(n,k);
for i:=1 to n do read(a[i]);
now:=-maxlongint;
a[0]:=-maxlongint;
for i:=1 to n do
begin
min:=a[i];
max:=a[i];
ans:=1;
if a[i]=a[i-1] then continue;
for j:=i+1 to n do
begin
if a[j]<min then min:=a[j];
if a[j]>max then max:=a[j];
if max-min<=k then
begin
if j-i+1>ans then ans:=j-i+1;
end
else break;
end;
if ans>now then now:=ans;
end;
writeln(now);
close(input);
close(output);
end.