#include <iostream>
#include <vector>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main() {
  int n, k;
  cin >> n >> k;
  vector <int> a(n);
  for (auto &v : a) {
    cin >> v;
  }
  
  vector <int> dp(n, 1);
  dp[0] = 1;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      if (a[j] - a[i] <= k && a[j] - a[i] >= -k)
        dp[i] = max(dp[i], dp[j] + 1);
    }
  }
  
  cout << dp[n - 1] << endl;
  return 0;
}