#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

struct Substr {
public:
    int length;
    char back;
};
bool operator<(const Substr& lhs, const Substr& rhs) {
    return lhs.length < rhs.length;
}

int main() {
    ll n, max_diff;
    cin >> n >> max_diff;

    vector<ll> a;
    rep(i, n) {
        ll a_i;
        cin >> a_i;
        a.push_back(a_i);
    }

    vector<ll> max_length(n, 0);
    rep(i, n) {
        ll max = -1;
        ll max_index = -1;
        for (ll k = i - 1; k >= 0; --k) {
            if (abs(a[k] - a[i]) <= max_diff && max_length[k] > max) {
                max = max_length[k];
                max_index = k;
            }
        }
        if (max_index == -1) {
            max_length[i] = 1;
        } else {
            max_length[i] = max_length[max_index] + 1;
        }
    }

    ll ans = *max_element(max_length.begin(), max_length.end());
    cout << ans << endl;
    return 0;
}
