#include <bits/stdc++.h>
using namespace std;
int ar[105];
int main() {
  int n, d, i, j, ans = 0;
  cin >> n >> d;
  for (i = 0; i < n; i++) cin >> ar[i];
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(ar, ar + n);
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (ar[j] - ar[i] <= d) ans = max(ans, j - i + 1);
    }
  }
  cout << n - ans << endl;
  return 0;
}
