#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n, d;
  cin >> n >> d;
  vector<int> s;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    s.push_back(a);
  }
  sort(s.begin(), s.end());
  int res = 0;
  while (s[s.size() - 1] - s[0] > d) {
    if (s.size() <= 1) break;
    if (s[1] - s[0] > s[s.size() - 1] - s[s.size() - 2])
      s.erase(s.begin());
    else
      s.erase(s.begin() + s.size() - 1);
    res++;
  }
  cout << res << endl;
  return 0;
}
