
#include <bits/stdc++.h>
// https://boostjp.github.io/tips/multiprec-int.html
// https://boostjp.github.io/tips/multiprec-float.html
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using namespace std;

#define ll long long
#define ld long double
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct UnionFind {
    ll n;
    vector<ll> par,rank;

    UnionFind(ll N) : par(N) {
        n = N;
        REP(i,n) par[i] = i;
        rank.assign(n, 1);
    }

    ll root(ll x) {
        ll tmp = x;
        while(par[tmp] != tmp) {
            tmp = par[tmp];
        }
        return par[x] = tmp;
    }

    void unite(ll x, ll y) {
        ll rootX = root(x);
        ll rootY = root(y);
        if (rootX == rootY) return;
        rank[rootY] += rank[rootX];
        par[rootX] = rootY;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll count(ll x) {
        return rank[root(x)];
    }
};

ll n,m,k;
int main() {
    INIT();

    cin >> n >> k;

    vector<ll> a(n),dp(n+1);
    REP(i,n) {
        cin >> a[i];
    }
    REP(i, n - 1) {
        REPS(j, i + 1, n) {
            if(abs(a[i] - a[j]) <= k) {
                chmax(dp[j], dp[i] + 1);
                break;
            }
        }
    }
    cout << max(dp[n - 2], dp[n - 1]) + 1;
}