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