#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (long long int i = 0; i < n; ++i) cin >> a[i];
  vector<long long int> dp(n + 1, 1);
  for (long long int i = 1; i < n; ++i) {
    for (long long int j = i - 1, c = 0; j >= 0 && c < 102; --j, c++) {
      if (abs(a[i] - a[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
    }
  }
  cout << dp[n - 1];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
