#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 7, oo = 1e18, base = 311, mod = 1e9 + 7;
const double PI = 3.141592654;
long long t, n, a[maxn], res, f[maxn], k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long i = (1); i <= (n); ++i) cin >> a[i];
  f[1] = 1;
  for (long long i = (2); i <= (n); ++i)
    for (long long j = (1); j <= (i - 1); ++j)
      if (abs(a[i] - a[j]) <= k) f[i] = max(f[i], f[j] + 1);
  for (long long i = (1); i <= (n); ++i) res = max(res, f[i]);
  cout << res;
}
