#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (int)1e9 + 5;
const ll infl = (ll)1e18 + 5;
const int mod = 1e9 + 7;
const int nax = 3e5 + 10;
int v[nax];
vector<vector<int>> dp(nax, (vector<int>(2, -1)));
int n, k;
int go(int index, int last, bool ok = 0) {
  if (index == n) return 0;
  int best = 0;
  if (dp[index][0] != -1)
    best = dp[index][0];
  else {
    best = go(index + 1, last, ok);
    dp[index][0] = best;
  }
  if (!ok && abs(v[index] - last) > k) {
    return best;
  }
  if (dp[index][1] != -1)
    best = max(best, dp[index][1]);
  else {
    dp[index][1] = go(index + 1, v[index]) + 1;
    best = max(best, dp[index][1]);
  }
  return best;
}
void solve() {
  cin >> n >> k;
  for (int i = 0; i < (n); ++i) cin >> v[i];
  cout << go(0, 0, 1) << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
