#include <bits/stdc++.h>
using namespace std;
int n, k, p = -1;
vector<int> a, dp;
int rec(int i) {
  if (i == n) return 0;
  if (dp[i] != -1 and abs(p - a[i]) <= k) return dp[i];
  dp[i] = max(dp[i], 1);
  if (abs(p - a[i]) <= k or p == -1) {
    int tmp = p;
    p = a[i];
    dp[i] = 1 + rec(i + 1);
    p = tmp;
  }
  return dp[i] = max(dp[i], rec(i + 1));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  a.assign(n, 0);
  dp.assign(n, -1);
  for (auto &x : a) cin >> x;
  cout << rec(0);
}
