#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1 << 30;
constexpr int mo = 1e9 + 7;
constexpr ll infl = 1ll << 60;
int main() {
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  map<int, int> m;
  m[v[0]] = 1;
  for (int i = 1; i < n; ++i) {
    int tmp = 1;
    for (auto &a : m) {
      if (abs(a.first - v[i]) <= k) {
        tmp = max(tmp, a.second + 1);
      }
    }
    m[v[i]] = tmp;
  }
  int ret = 0;
  for (auto &a : m) {
    ret = max(a.second, ret);
  }
  cout << ret << endl;
  return 0;
}
