#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long cnt = 0, ans = 0;
const int MAX = 510000;
struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
int main() {
  int n, a[n], k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n];
  for (int i = 0; i < n; i++) dp[i] = 1;
  for (int i = 2; i < n; i++) {
    for (int j = 1; i - j >= 0; j++) {
      if (abs(a[i] - a[i - j]) <= k) {
        dp[i] = max(dp[i], dp[i - j] + 1);
      }
    }
  }
  cout << dp[n - 1] << endl;
}
