#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
  preprocess() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} ____;
int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vv<int> dp(n + 1, vector<int>(2));
  vv<int> dp2(n + 1, vector<int>(2, -1));
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(2); j++) {
      if (dp2[i][j] == -1 || abs(dp2[i][j] - a[i]) <= k) {
        if (chmax(dp[i + 1][0], dp[i][j] + 1)) {
          dp2[i + 1][0] = a[i];
        }
      }
      if (chmax(dp[i + 1][1], dp[i][j])) {
        dp2[i + 1][1] = dp2[i][j];
      }
    }
  cout << max(dp[n][0], dp[n][1]) << '\n';
}
