#include <bits/stdc++.h>
using namespace std;
int f[105];
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) cin >> f[i];
  sort(f + 1, f + n + 1);
  if (f[n] - f[1] <= d) {
    cout << "0" << endl;
    return 0;
  }
  int minn = 105;
  for (int i = 1; i <= n - 1; i++) {
    int a = f[i] + d, c = i - 1;
    for (int j = n; j > i; j--) {
      if (f[j] <= a) break;
      c++;
    }
    minn = min(minn, c);
  }
  cout << minn << endl;
  return 0;
}
