#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, counter = 0;
  cin >> n >> d;
  vector<int> points;
  for (int i = 0; i < n; i++) {
    int point;
    cin >> point;
    points.push_back(point);
  }
  sort(points.begin(), points.end());
  int smallest = points[0];
  int i = 0;
  while (points[points.size() - 1] - smallest > d) {
    points.pop_back();
    counter++;
  }
  cout << counter;
  return 0;
}
