#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define eb emplace_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define cinarr(A,len) for(int i=0;i<len;i++){cin>>A[i];}
#define coutarr(A,len) for(int i=0;i<len;i++){cout<<A[i]<<' ';}cout<<endl
#define coutin(V) for(auto& i : V){cout << i << ' ';}cout<<endl // for vect and set
#define coutmap(U) for(auto& i : U){cout << i.first << "->" << i.second << ", ";}cout<<endl // for map
#define deb(x) cerr << #x << '\t' << x << endl
const int imax = numeric_limits<int>::max(), imin = numeric_limits<int>::min();
const long long	lmax = numeric_limits<long long>::max(), lmin = numeric_limits<long long>::min();
/*========================================================================*/
/* strategi/note:

/*========================================================================*/

bool Svd=0;
void solve(){Svd=1;
	// O(n^2) ?
	int n, k;
	cin >> n >> k;
	int a[n];
	cinarr(a,n);
	int dp[n] = {0}; // longest subsequence till ith
	dp[0] = 1; 
	for(int i = 1; i<n; i++){
		bool found = false;
		for(int j = i-1; j>=0; j--){
			if(abs(a[i]-a[j])<=k){
				dp[i] = max(dp[i], // old (another j)
							dp[j] + 1);
				found = true;
			}
		}
		if(!found){
			dp[i] = 1;
		}
	}
	cout << dp[n -1] << endl;
}

/*========================================================================*/
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
//cout<<fixed<<setprecision( ); // iomanip **
 solve();
 //int t;cin>>t;while(t--){solve();}
if(!Svd)cout<<"solve() function blm dipanggil!"<<endl;
//cout.flush(); cin.get();
return 0;
}
