#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int dp[(long long int)3e5 + 1];
long long int ans(long long int in[], long long int n, long long int k) {
  dp[n - 1] = 1;
  for (long long int i = n - 2; i >= 0; i--) {
    dp[i] = 1;
    for (long long int j = i + 1; j < n; j++) {
      if (abs(in[i] - in[j]) <= k) dp[i] = max(dp[j] + 1, dp[i]);
    }
  }
  return dp[0];
}
void Panda() {
  long long int n, k;
  cin >> n >> k;
  long long int in[n];
  for (long long int i = 0; i < n; i++) cin >> in[i];
  cout << ans(in, n, k) << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Panda();
  return 0;
}
