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

#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007


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

        }
        dp[i]=max_val;
    }
    //rep(i,n)cout << dp[i] <<" ";
    cout << dp[n-1] << endl;
}