#include<bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<pair<int, int>> dp;
    dp.emplace_back(0, a[0]);
    rep(i, n) {
        int j = 0;
        sort(dp.rbegin(), dp.rend());
        while(abs(dp[j].second - a[i]) > k) j++;
        dp.emplace_back(dp[j].first + 1, a[i]);
    }
    sort(dp.rbegin(), dp.rend());
    cout << dp[0].first << endl;
    return 0;
}