/**
 * author: said_v15
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
typedef long long  ll;

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define pb push_back 
#define sc second 
#define f first 
#define kek cout<<"\n"; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 


const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int MAXN = 305;
const int INF = 1e8;
const ll LL_INF=1e18;
const double pi=3.1415926535;
using namespace std;
int divide(int a, int b)
{
          return (a+b-1)/b;
}

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 fast;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 
 int questions=1;
 // cin>>questions;
 while(questions--)
 {
      int n,k;
      cin>>n>>k;
      vector<int> v(n);
      forn cin>>v[i];
      vector<int> dp(n+1,1);
      for(int i=0;i<n;i++) 
      {
               for(int j=i-1;j>=0;j--) 
               {
                         if(abs(v[i]-v[j])<=k) {
                                   dp[i]=max(dp[i], dp[j]+1);
                         }
               }
               if(i) dp[i]=max(dp[i],dp[i-1]);
      }
      cout<<dp[n-1];
    
 }
    
 
 // !!! LOOK AT NUMBER OF QUESTIONS IN A PROBLEM !!! (cin>>questions)
 

  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
}