#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> a(300000);
int maxCount = 0;
void dfs(int, int, int, bool);
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  dfs(a.at(0), 0, 0, false);
  cout << maxCount << endl;
}
void dfs(int before_num, int i, int count, bool is_before_skipped) {
  if (i == n) {
    if (count > maxCount) {
      maxCount = count;
    }
    return;
  }
  if (abs(a.at(i) - before_num) > k) {
    dfs(before_num, i + 1, count, is_before_skipped);
  } else {
    dfs(a.at(i), i + 1, count + 1, false);
    if (!is_before_skipped) {
      dfs(before_num, i + 1, count, true);
    }
  }
}
