#include <bits/stdc++.h>
using namespace std;
const long long N = 3 * 1e5 + 5, Mod = 1e9 + 7;
long long dp[N];
long long v[N];
long long n, k;
long long res(long long id, long long prev) {
  if (id == n) return 0;
  long long &ans = dp[id];
  if (ans != -1 and abs(prev - v[id]) <= k) return ans;
  ans = 0;
  if (abs(prev - v[id]) <= k) {
    ans = 1 + res(id + 1, v[id]);
  }
  ans = max(ans, res(id + 1, prev));
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> v[i];
  memset(dp, -1, sizeof(dp));
  long long ans = 0;
  ans = res(0, v[0]);
  cout << ans;
  return 0;
}
