#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, a[1000] = {0};
  int n, d;
  cin >> n >> d;
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int c = 0, mi = 9999;
  for (i = 0; i < n; i++) {
    c = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] - a[i] > d || a[j] - a[i] < 0) c++;
    }
    mi = min(mi, c);
  }
  cout << mi;
  return 0;
}
