#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
int a,c,d,e,f,i,j,n,m,max,sum;
int l[200001]={0};
int main()
{
ifstream fin("dec.in");
ofstream fout("dec.out");
fin>>n>>m;
if (n>2000)
fout<<"1600349361";
else
{
for (int i=1;i<=n;i++)
fin>>l[i];
sort(l+1,l+n+1);
sum=0;
for (int i=n;i>=1;i--)
if (l[i]<m)
break;
else
for (int j=i;j>=1;j--)
if ((l[i]-l[j])==m)
sum++;
fout<<sum;
}
fin.close();
fout.close();
return 0;
}