#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using vstr = vector<string>;
const ll MOD = 1e9 + 7;
const ll INF = 1ll << 60;
int N, K;
int main() {
  cin >> N >> K;
  int A[N], L[N];
  for (int i = 0; i < (int)(N); ++i) {
    cin >> A[i];
    L[i] = 1;
  }
  int ans = 0;
  for (int i = 1; i < N; i++) {
    for (int j = i - 1; j >= 0; j--) {
      int dist = abs(A[i] - A[j]);
      if (dist <= K) {
        L[i] = max(L[i], L[j] + 1);
      }
    }
    ans = max(ans, L[i]);
  }
  cout << ans << endl;
  return 0;
}
