#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vi dp(n, 1);
  int mx = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= i; j++) {
      if (abs(a[i] - a[i - j]) <= k) {
        dp[i] = dp[i - j] + 1;
        if (i - j <= mx) break;
      }
    }
    if (dp[i] - dp[i - 1] >= 0) mx = i;
  }
  cout << dp[n - 1] << endl;
}
