#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d, seq[110];
  cin >> n >> d;
  for (int i = 0; i < n; ++i) {
    cin >> seq[i];
  }
  sort(seq, seq + n);
  int cnt = 0, start = 0, end = 0;
  while (end < n) {
    if (seq[end] - seq[start] <= d) {
      cnt = max(cnt, end - start + 1);
      ++end;
    } else
      ++start;
  }
  cout << n - cnt << endl;
  return 0;
}
