#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  vector<int> a;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int counter = 0;
  while (true) {
    if (d < (a[n - 1] - a[0])) {
      n--;
      counter++;
    } else
      break;
  }
  cout << counter;
  return 0;
}
