#include <cstdio>
#include <iostream>
using namespace std;
long long a[200000]={0};
long long abslong(long long a)
{
if (a<0)
return(-a);
else
return(a);
}
int main(void)
{
freopen("dec.in","r",stdin);
freopen("dec.out","w",stdout);
int i,j,n;
long long c,total=0;
cin>>n>>c;
for (i=0;i<n;i++)
cin>>a[i];
for (i=0;i<n;i++)
for (j=i+1;j<n;j++)
if (abslong(a[i]-a[j])==c)
total++;
cout<<total<<endl;
fclose(stdin);
fclose(stdout);
return(0);
}