#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 a = 0, b = 0;
  int c;
  c = f[n] - d;
  for (int i = 1; i <= n; i++) {
    if (f[i] >= c) break;
    a++;
  }
  c = f[1] + d;
  for (int i = n; i >= 1; i--) {
    if (f[i] <= c) break;
    b++;
  }
  if (a < b)
    cout << a << endl;
  else
    cout << b << endl;
  return 0;
}
