#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, d;
  cin >> n >> d;
  vector<int> a(n);
  int minn = 200, Max = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] < minn) minn = a[i];
    if (a[i] > Max) Max = a[i];
  }
  if (Max - minn <= d) {
    cout << 0;
    return 0;
  }
  sort(a.begin(), a.end());
  int maxx = -1;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j)
      if ((a[j] - a[i] <= d) && (j - i > maxx)) maxx = j - i;
  }
  maxx++;
  maxx += (d == 0);
  cout << n - maxx;
  return 0;
}
