#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);
  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;
        break;
      }
    }
    dp[i] = max(dp[i], dp[i - 1]);
  }
  cout << dp[n - 1] << endl;
}
