#include <bits/stdc++.h>
using namespace std;
constexpr long long mod = 1000000007;
long long n, k;
vector<long long> rec, a;
long long dfs(long long cur) {
  if (rec[cur] != -1) return rec[cur];
  long long res = 0;
  for (long long i = (cur + 1); i < (long long)(n); i++) {
    if (abs(a[i] - a[cur]) <= k) res = max(res, dfs(i));
  }
  res++;
  return rec[cur] = res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  rec.resize(n, -1);
  a.resize(n);
  for (long long i = (0); i < (long long)(n); i++) cin >> a[i];
  dfs(0);
  long long ans = *max_element(rec.begin(), rec.end());
  cout << ans << endl;
  return 0;
}
