#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2e5+5;
ll a[N];
ll n,c,ans;
ll find(int x)
{ ll res=0;
int h=0,t=n;
int mid;
while(h+1!=t)
{ mid=(h+t)/2;
if(a[mid]>=x) t=mid;
else h=mid;
}
while(a[t]==x)
{
t++;
res++;
}
return res;
}
int main()
{ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n>>c;
for(int i=1;i<=n;i++) cin>>a[i];
sort(a+1,a+n+1);
for(int i=n;i>=1;i--)
{ int tmp=find(a[i]-c);
if(tmp) ans+=tmp;
}
cout<<ans;
return 0;
}