#include <bits/stdc++.h>
const long long INF = 2e18;
const long long N = 1e6 + 1;
const long long mod = 1e9 + 1;
const long double eps = 1E-7;
using namespace std;
int a[101];
void solve() {
  int n, d;
  cin >> n >> d;
  if (n == 1) {
    cout << 0 << endl;
    return;
  }
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n - 1;) {
    if (a[n - 1 - i] - a[0] <= d) {
      cout << i << endl;
      return;
    } else {
      i++;
    }
  }
}
bool mtest = false;
int main() {
  ios_base::sync_with_stdio(0);
  int TE = 1;
  if (mtest) cin >> TE;
  while (TE--) solve();
  return 0;
}
