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