#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,ll>;
const ll inf=1000000000007;
const int mod=1000000007;


int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);

  vector<int> rans(n,1);
  for(int i=n-2; i>=0;i--){
    int val=a[i];
    for(int j=i+1; j<n; j++){
      if(abs(val-a[j])<=k) {
          rans[i]+= rans[j];
          break;          
      }
    }
  }
  int mx=0;
  rep(i,0,n) mx=max(ans[i],mx);
  rep(i,0,n) mx=max(rans[i],mx);
  cout << mx << endl;
//  rep(i,0,n) cout << ans[i] << ' ';
//  cout << endl;
//  rep(i,0,n) cout << rans[i] << ' ';
//  cout << endl;

  return 0;



}
