#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
long long int n, k, a[N];
long long int solve(int i, int pre) {
  if (i >= n) return 0;
  long long int mx = 0;
  if (abs(pre - a[i]) <= k) {
    mx = max(mx, solve(i + 1, a[i]) + 1);
    mx = max(mx, solve(i + 1, pre));
  }
  mx = max(mx, solve(i + 1, pre));
  return mx;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << solve(0, a[0]);
  return 0;
}
