#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
vector<long long> start(300008, 0);
int main() {
  cin >> n >> k;
  long long prev_inp, prev = -1, ans = 0;
  for (long long i = 0; i < n; i++) {
    if (0) cout << " -- prev " << prev << " ans " << ans << "--" << endl;
    cin >> m;
    if (i == 0) {
      start[m] = 1;
      if (0) cout << " in first " << endl;
      continue;
    }
    if (ans == 0) {
      long long lo = m - k, hi = m + k;
      if (lo < 0) lo = 0;
      for (long long j = lo; j < hi + 1; j++) {
        if (start[j]) {
          ans = 2;
          prev = m;
          break;
        }
      }
      start[m] = 1;
    } else {
      if (abs(prev - m) <= k) {
        if (0) cout << " Got one !";
        prev = m;
        ans++;
        if (0) cout << " prev " << m << " ans " << ans << endl;
      }
    }
  }
  cout << ans;
  cin >> n;
}
