#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0l);
const long long MOD = 1e9 + 7;
bool debug = 1;
const int N = 1;
int main() {
  long long n, d;
  cin >> n >> d;
  vector<int> v(n);
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  sort(v.begin(), v.end());
  int maxtam = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i + 1; j++) {
      if (v[i] - v[j] <= d) {
        maxtam = max(maxtam, i - j + 1);
      }
    }
  }
  cout << n - maxtam << endl;
  return 0;
}
