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