#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1e18;
struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
  int group_num(int n) {
    set<int> s;
    for (int i = 0; i < n; ++i) {
      s.insert(root(i));
    }
    return int(s.size());
  }
};
int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> d(n + 5, 1);
  for (ll i = 0; i < (n); ++i) cin >> a[i];
  for (ll i = 0; i < (n - 1); ++i) {
    for (ll j = 0; j < (i + 1); ++j) {
      if (abs(a[i + 1] - a[j]) <= k) {
        d[i + 1] = max(d[i + 1], d[j] + 1);
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < (n + 1); ++i) {
    ans = max(ans, d[i]);
  }
  cout << ans;
}
