#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, cnt, s = -1;
  cin >> n >> d;
  int a[n];
  if (n == 1) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cnt = 0;
    for (int j = i; j < n; j++) {
      if (abs(a[i] - a[j]) <= d) cnt++;
    }
    if (cnt > s) {
      s = cnt;
    }
  }
  cout << n - s;
  return 0;
}
