program dec1;
var
n,m,i,j,ans,t:longint;
a:array[1..200000] of longint;
procedure sort(l,r:longint);
var
i,j,mid:longint;
begin
i:=l;j:=r;mid:=a[random(j-i+1)+i];
repeat
while a[i]<mid do inc(i);
while a[j]>mid do dec(j);
if not(i>j) then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
inc(i);dec(j);
end;
until i>j;
if l<j then sort(1,j);
if i<r then sort(i,r);
end;
begin
assign(input,'dec.in');
assign(output,'dec.out');
reset(input);
rewrite(output);
readln(n,m);
for i:=1 to n do read(a[i]);
sort(1,n);
for i:=n downto 2 do
for j:=i-1 downto 1 do
if a[i]-a[j]=m then
ans:=ans+1;
writeln(ans);
close(input);
close(output);
end.