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