#include <bits/stdc++.h>
using namespace std;
using namespace std;
vector<int> v;
int ans = 100000;
int val = 10000;
int idx = 100000;
int main() {
  int a, d;
  cin >> a >> d;
  for (int i = 0; i < a; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  for (int j = 0; j < v.size(); j++) {
    ans = 100000;
    for (int i = 0; i < v.size(); i++) {
      int cnt = i - 0;
      int p = j - cnt;
      if (cnt > j) break;
      ans = min(ans, (v[a - p - 1] - v[i]));
    }
    if (idx > j && ans <= d) {
      val = ans;
      idx = j;
    }
  }
  cout << idx << endl;
}
