#include <bits/stdc++.h>
using namespace std;
int p[100001],n,dist,i,ans;
int main(void)
{
scanf ("%d%d",&n,&dist);
for (;i<n;i++)
scanf ("%d",&p[i]);
sort(p,p+n);
for (i=1;i<n-1;i++)
if (p[i-1]!=0&&p[i+1]-p[i-1]<=dist)p[i]=0,ans++;
else
{
int j=i-1;
while (p[j]==0)j--;
if (p[i+1]-p[j]<=dist)p[i]=0,ans++;
}
printf ("%d",ans);
}
using namespace std;
int p[100001],n,dist,i,ans;
int main(void)
{
scanf ("%d%d",&n,&dist);
for (;i<n;i++)
scanf ("%d",&p[i]);
sort(p,p+n);
for (i=1;i<n-1;i++)
if (p[i-1]!=0&&p[i+1]-p[i-1]<=dist)p[i]=0,ans++;
else
{
int j=i-1;
while (p[j]==0)j--;
if (p[i+1]-p[j]<=dist)p[i]=0,ans++;
}
printf ("%d",ans);
}