#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  deque<int> l;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    l.push_back(t);
  }
  int removes = 0;
  int mxdif = 1e8;
  while (mxdif > k) {
    sort(l.begin(), l.end());
    mxdif = l[l.size() - 1] - l[0];
    if (mxdif > k) {
      l.pop_back();
      removes++;
    }
  }
  cout << removes << endl;
  return 0;
}
