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