#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long cnt = 0, ans = 0;
const int MAX = 510000;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n];
  for (int i = 0; i < n; i++) dp[i] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 1; i - j >= 0; j++) {
      if (abs(a[i] - a[i - j]) <= k) {
        dp[i] = max(dp[i], dp[i - j] + 1);
        break;
      } else
        continue;
    }
  }
  cout << dp[n - 1] << endl;
}
