#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, d0;
  cin >> n >> d0;
  int x[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  if (n == 1) {
    cout << "0\n";
    return;
  }
  sort(x, x + n);
  int res = 101;
  for (int i = 0; i < n - 1; i++) {
    int cnt = 1;
    for (int j = i + 1; j < n; j++) {
      int d = x[j] - x[i];
      if (d > d0) {
        break;
      }
      cnt++;
    }
    int del = n - cnt;
    if (del < res) {
      res = del;
    }
  }
  cout << res << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  solve();
  return 0;
}
