#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 3e5 + 10;
int maps[N];
int k, n;
int v[N];
map<int, map<int, int>> dp;
int dfs(int i, int lst) {
  if (i >= n) {
    return 0;
  }
  if (dp[i][lst] != 0) {
    return dp[i][lst];
  }
  int &ans = dp[i][lst];
  ans = max(ans, dfs(i + 1, lst));
  ans = max(ans, dfs(i + 1, v[i]));
  if (abs(v[i] - lst) <= k) {
    ans = max(ans, 1 + dfs(i + 1, v[i]));
  } else {
    ans = max(ans, dfs(i + 1, v[i]));
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  cout << dfs(0, v[0]) << "\n";
  return 0;
}
