#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
const ll M = 1e9 + 7;
ll longest(vl &a, ll i, ll n, ll k) {
  ll ma = 1;
  for (ll j = i + 1; j < (ll)(n); j++) {
    if (abs(a[i] - a[j]) <= k) ma = max(ma, longest(a, j, n, k) + 1);
  }
  return ma;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, k;
  cin >> n >> k;
  vl a(n);
  for (ll i = 0; i < (ll)(n); i++) cin >> a[i];
  cout << longest(a, 0, n, k) << endl;
}
