#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using graph = vector<vector<ll>>;
const long long inf = 2147483647;
const ll INF = 9223372036854775807;
signed main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  priority_queue<P> t;
  vector<P> l;
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < t.size() + 1; j++) {
      if (j == t.size()) {
        t.push({1, a[i]});
        break;
      }
      P c = t.top();
      t.pop();
      l.push_back(c);
      if (abs(c.second - a[i]) <= k) {
        t.push({c.first + 1, a[i]});
        break;
      }
    }
    for (auto g : l) t.push(g);
    l.clear();
  }
  cout << t.top().first << "\n";
  return 0;
}
