var
n,k,i,ans,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]);
ans:=-maxlongint;
a[0]:=-maxlongint;
for i:=1 to n do
begin
min:=a[i];
max:=a[i];
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;
end;
writeln(ans);
close(input);
close(output);
end.