#include <bits/stdc++.h>
using namespace std;
long long fpow(long long a, long long b, long long mod) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long prod = fpow(a, b / 2, mod) % mod;
  long long ans = (prod * prod) % mod;
  if (b % 2) return (ans * a) % mod;
  return ans;
}
long long c = 1e18;
long long f(long long i, long long curr, long long n, long long k,
            vector<long long> &v, vector<long long> &dp) {
  if (i >= n) return 0;
  if (dp[i] > 0) return dp[i];
  if (curr == 1e18 || abs(curr - v[i]) <= k) {
    long long c1 = 1 + f(i + 1, v[i], n, k, v, dp),
              c2 = f(i + 1, curr, n, k, v, dp), c3 = f(i + 1, c, n, k, v, dp);
    return dp[i] = max(c1, max(c2, c3));
  }
  long long c1 = f(i + 1, curr, n, k, v, dp), c2 = f(i + 1, c, n, k, v, dp);
  return dp[i] = max(c1, c2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (auto &it : v) cin >> it;
  vector<long long> dp(n);
  long long curr = 1e18;
  f(0, curr, n, k, v, dp);
  cout << dp[0] << "\n";
}
