#include <bits/stdc++.h>
using namespace std;
long long res;
long long n, k;
long long v[301001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v, v + n);
  int in = 0, fin = n - 1;
  while (abs(v[in] - v[fin]) > k) {
    if (abs(v[in] - v[fin - 1]) <= abs(v[in + 1] - v[fin]))
      fin--;
    else
      in++;
    res++;
  }
  long long res1 = res;
  res = 0;
  in = 0, fin = n - 1;
  while (abs(v[in] - v[fin]) > k) {
    if (abs(v[in] - v[fin - 1]) < abs(v[in + 1] - v[fin]))
      fin--;
    else
      in++;
    res++;
  }
  cout << min(res1, res) << "\n";
}
