#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  vector<int> els(n);
  for (auto& e : els) cin >> e;
  sort(els.begin(), els.end());
  int l = 0, r = n - 1;
  int counter = 0;
  while (els[r] - els[l] > d) {
    int v1 = els[l + 1] - els[l];
    int v2 = els[r] - els[r - 1];
    if (v1 > v2)
      l++;
    else
      r--;
    counter++;
  }
  cout << counter;
}
