#include <bits/stdc++.h>
using namespace std;
const int N = 301234;
int a[N];
int dp[N];
int n, k, mx = 0;
int ans(int in, int lst) {
  if (in < 0 || in >= n) return 0;
  mx = max(mx, dp[in]);
  int x =
      max(mx, (abs(lst - a[in]) <= k || lst == -1) * (1 + ans(in + 1, a[in])));
  mx = max(mx, x);
  return dp[in] = max(mx, x);
}
void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  ans(0, -1);
  cout << *max_element(dp, dp + n);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
