#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long 
#define f(j) for(ll i=0;i<j;i++)
#define pb(i) push_back(i)
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;    
typedef vector<vector<long long> > matrix; 
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	// faster
	int n,k;
	cin>>n>>k;
	int a[n];
	f(n)	cin>>a[i];
	int dp[n]={1},ans=1;
	dp[0]=1;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=0;j--)
			if(abs(a[i]-a[j])<=k)
				dp[i] = max(dp[i],dp[j]+1);
		ans = max(ans,dp[i]);
	}

	cout<<ans<<"\n";
return 0;	
}