#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k; cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  vector<vector<int>> G(n);
  REP(i,n){
    FOR(j,i+1,n){
      if(abs(a[i]-a[j])<=k){
        G[j].push_back(i);
        break;
      }
    }
  }

  int ans = 1;
  //vector<bool> seen(n, false);
  auto dfs = [&](auto && self, int cur, int cnt) -> void{
		//seen[cur] = true;
		for(auto next: G[cur]){
			//if(seen[next]) continue;
			self(self, next, cnt+1);
		}
    chmax(ans, cnt);
  };
  REPR(i,n){
    //if(seen[i]) continue;
    dfs(dfs, i, 1);
  }
  cout << ans << endl;
  return 0;
}
