#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 77;
long long A[N], dp[N];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; ++i) {
    cin >> A[i];
  }
  dp[1] = 1;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = max(1LL, i - 123); j < i; ++j)
      if (abs(A[i] - A[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) ans = max(ans, dp[i]);
  cout << ans << '\n';
  return 0;
}
