#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  int rj = 150;
  for (int i = 0; i < v.size() - 1; i++) {
    for (int j = 1; j + i < v.size(); j++) {
      if (v[i + j] - v[i] <= k) {
        int tmp = 0;
        tmp = i;
        tmp += v.size() - (i + j);
        rj = min(rj, tmp);
      }
    }
  }
  cout << rj - 1;
}
