#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, i, j;
  cin >> n >> d;
  vector<int> vv;
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    vv.push_back(x);
  }
  int ans = 0;
  sort(vv.begin(), vv.end());
  for (;;) {
    int dia = vv[vv.size() - 1] - vv[0];
    if (dia <= d) {
      break;
    }
    int pos1, pos2;
    for (j = 0; j < vv.size(); j++) {
      int dif = vv[j] - vv[0];
      if (dif < 0) dif = -dif;
      if (dif > d) {
        pos1 = j;
        break;
      }
    }
    int ff = pos1 + 1;
    for (j = vv.size() - 1; j >= 0; j--) {
      int dif = vv[vv.size() - 1] - vv[j];
      if (dif < 0) dif = 0;
      if (dif > d) {
        pos2 = j;
        break;
      }
    }
    int sz = vv.size();
    int ss = (n - pos2) - 1;
    if (ff < ss) {
      vv.erase(vv.begin());
      ans++;
    } else {
      vv.pop_back();
      ans++;
    }
  }
  cout << ans << endl;
}
