#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

void solve(long long N, long long K, std::vector<long long> A)
{
    set<pair<ll, ll>> q;
    q.insert(make_pair(1, A[0]));
    for (int i = 1; i < N; i++)
    {
        set<pair<ll,ll>> another;
        for (auto p : q)
        {   
            if (abs(p.second - A[i]) <= K)
            {
                another.insert(make_pair(p.first + 1, A[i]));
            }else{
                another.insert(p);
                another.insert(make_pair(1,A[i]));
            }
        }

        q = another;
    }

    ll ans = 0;
    for (auto &&i : q)
    {
        ans = max(i.first,ans);
    }
    cout << ans << endl;
    
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}
