#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1000000000;
class UnionFind {
 public:
  vector<int> par;
  UnionFind(int N) {
    par.resize(N);
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int A) {
    if (par[A] == A) return A;
    return par[A] = root(par[A]);
  }
  bool unite(int A, int B) {
    A = root(A);
    B = root(B);
    if (A == B) {
      return false;
    }
    par[B] = A;
    return true;
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (long long int i = (0); i < (n); i++) cin >> a[i];
  vector<int> dp(n, 1);
  for (long long int i = (0); i < (n); i++) {
    for (long long int j = (i + 1); j < (n); j++) {
      if (abs(a[i] - a[j]) <= k) {
        dp[j] = max(dp[i] + 1, dp[j]);
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}
