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