#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d;
  scanf("%lld", &n);
  scanf("%lld", &d);
  long long ar[n];
  for (long long i = 0; i < n; i++) scanf("%lld", &ar[i]);
  sort(ar, ar + n);
  long long r = n - 1, k = 0;
  while (r >= 0) {
    if (ar[r] - ar[0] > d)
      r--, k++;
    else
      break;
  }
  printf("%lld\n", k);
}
