#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
int k;
vi memo;
int dfs(vi const& a, int idx) {
  int max_depth = 1;
  for (int i = idx + 1; i < a.size(); i++) {
    if (abs(a[idx] - a[i]) > k) continue;
    int depth;
    if (memo[i] == -1)
      depth = dfs(a, i) + 1;
    else
      depth = memo[i] + 1;
    if (max_depth < depth) max_depth = depth;
  }
  return memo[idx] = max_depth;
}
void resuelveCaso() {
  int n;
  cin >> n >> k;
  vi a(n);
  for (int& e : a) cin >> e;
  memo.resize(n, -1);
  cout << dfs(a, 0) << '\n';
}
int main() {
  int T;
  T = 1;
  for (int i = 1; i <= T; i++) {
    resuelveCaso();
  }
  return 0;
}
