#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
long long n, k;
long long a[N];
long long dp[N];
long long solve(long long idx, long long lst) {
  if (idx == n + 1) return 0;
  long long &ans = dp[lst];
  if (ans != -1) return ans;
  long long op1 = solve(idx + 1, lst);
  long long op2 = 0;
  if (idx == 1) {
    op2 = 1 + solve(idx + 1, a[idx]);
  } else {
    if (abs(a[idx] - lst) <= k) {
      op2 = 1 + solve(idx + 1, a[idx]);
    }
  }
  return ans = max(op1, op2);
}
void solve() {
  cin >> n >> k;
  memset(dp, -1, sizeof dp);
  for (long long i = 1; i <= n; i++) cin >> a[i], a[i]++;
  long long ans = solve(1, 0);
  cout << ans << '\n';
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) solve();
}
