#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int dp[n+1] = {-1};
    dp[0] = 1;
    for (int i=1; i<=n; i++) {
        dp[i] = dp[i-1];
        for (int j=1; j<=i; j++) {
            if (dp[i-j]+1 < dp[i]) break;
            if (abs(a[i] - a[i-j]) <= k) {
                dp[i] = max(dp[i-j]+1, dp[i]);
            }
            else dp[i] = max(dp[i-j], dp[i]);
        }
    }
    cout << dp[n] << endl;
    return 0;
}