#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> values(n);
  vector<int> dp(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    values[i] = a;
    dp[i] = 1;
    for (int j = 0; j < i; j++) {
      if (abs(values[j] - a) <= k) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
  }
  cout << dp[n - 1] << endl;
}
