#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[1000010],b[1000010]={0};
int s(int k)
{
int left=0;
int right=n-1;
while(left<=right){
int mid=(left+right)/2;
if(a[mid]==k) return 1;
else if(a[mid]>k) right=mid-1;
else if(a[mid]<k) left=mid+1;
}
return 0;
}
int main()
{
int sum=0;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
b[a[i]]++;
}
sort(a,a+n);
for(int i=0;i<n;i++)
{
if(s(a[i]-m))
for(int t=0;t<b[a[i]-m];t++)
sum++;
}
printf("%d",sum);
return 0;
}