#include <bits/stdc++.h>
using namespace std;
void solve(void) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  vector<int> dp(n + 1, 0);
  vector<vector<int>> gg(n + 1);
  dp[0] = 0;
  gg[0].push_back(0);
  dp[1] = 1;
  gg[1].push_back(1);
  for (int i = 2; i <= n; ++i) {
    dp[i] = dp[i - 1];
    for (auto j : gg[dp[i - 1]]) {
      if (abs(a[j] - a[i]) <= k) dp[i] = max(dp[i], dp[j] + 1);
    }
    gg[dp[i]].push_back(i);
  }
  cout << dp[n] << endl;
}
int main(void) { solve(); }
