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