#include <bits/stdc++.h>
using namespace std;
int x, k;
int a[300009], dp[300009];
int f(int i) {
  if (i == x) return 0;
  if (dp[i] != -1) return dp[i];
  int mx = 0;
  mx = max(mx, f(i + 1));
  for (int j = i + 1; j < x; j++) {
    if (abs(a[i] - a[j]) <= k) mx = max(mx, f(j) + 1);
  }
  return dp[i] = mx;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> x >> k;
  for (int i = 0; i < x; i++) cin >> a[i];
  memset(dp, -1, sizeof dp);
  cout << f(0) + 1;
  return 0;
}
