#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, d;
  cin >> n >> d;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  if (v[n - 1] - v[0] == d || v.size() == 1)
    cout << "0\n";
  else {
    for (long long int i = n - 1; i >= 0; i--) {
      if (v[i] - v[0] == d) {
        cout << n - i << endl;
        break;
      }
    }
  }
}
