#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, k, a[N], dp[N][5];
int solve(int i, int pre, bool f) {
  if (i == n) {
    return 0;
  }
  int &re = dp[i][f];
  if (re != -1) {
    return re;
  }
  re = solve(i + 1, pre, 0);
  if (pre == -1 || abs(pre - a[i]) <= k) {
    re = max(re, solve(i + 1, a[i], 1) + 1);
  }
  return re;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << solve(0, -1, 0) << endl;
  return 0;
}
