#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;
void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
  cout << head;
  if (sizeof...(Tail) > 0) cout << " ";
  print(tail...);
}
void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
  cout << head;
  print0(tail...);
}
template <class T>
class lsegment_tree {
 public:
  ll size;
  vector<T> data;
  T default_value;
  lsegment_tree(ll n, T default_value_) {
    default_value = default_value_;
    ll siz = 1;
    while (siz < n) {
      siz = siz * 2;
    }
    data.resize(siz * 2, default_value);
    size = siz;
  }
  ~lsegment_tree() {}
  T compare(T& a, T& b) { return max(a, b); }
  void update(ll k, T value) {
    k += size - 1;
    data[k] = value;
    while (k > 0) {
      k = (k - 1) / 2;
      data[k] = compare(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
  T query_open(ll a, ll b, ll k, ll l, ll r) {
    if (r <= a || b <= l) {
      return default_value;
    }
    if (a <= l && r <= b) {
      return data[k];
    }
    T vl = query_open(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query_open(a, b, k * 2 + 2, (l + r) / 2, r);
    return compare(vl, vr);
  }
  T query(ll a, ll b) { return query_open(a, b + 1, 0, 0, size); }
};
using lsegmenttree = lsegment_tree<ll>;
template <class T>
class ssegment_tree {
 public:
  ll size;
  vector<T> data;
  T default_value;
  ssegment_tree(ll n, T default_value_) {
    default_value = default_value_;
    ll siz = 1;
    while (siz < n) {
      siz = siz * 2;
    }
    data.resize(siz * 2, default_value);
    size = siz;
  }
  ~ssegment_tree() {}
  T compare(T& a, T& b) { return max(a, b); }
  void update(ll k, T value) {
    k += size - 1;
    data[k] = value;
    while (k > 0) {
      k = (k - 1) / 2;
      data[k] = compare(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
  T query_open(ll a, ll b, ll k, ll l, ll r) {
    if (r <= a || b <= l) {
      return default_value;
    }
    if (a <= l && r <= b) {
      return data[k];
    }
    T vl = query_open(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query_open(a, b, k * 2 + 2, (l + r) / 2, r);
    return compare(vl, vr);
  }
  T query(ll a, ll b) { return query_open(a, b + 1, 0, 0, size); }
};
using ssegmenttree = ssegment_tree<ll>;
ll maxrightl(lsegmenttree& lst, ll l0, ll r0, ll K, ll x) {
  ll lower = l0;
  ll upper = r0;
  ll result = INF;
  while (upper >= lower) {
    ll right = (lower + upper) / 2;
    ll maxval = lst.query(l0, right);
    if (maxval < x + K) {
      result = right;
      lower = right + 1;
    } else {
      upper = right - 1;
    }
  }
  return result;
}
ll minlefts(ssegmenttree& sst, ll l0, ll r0, ll N) {
  ll lower = l0;
  ll upper = r0;
  ll result = INF;
  for (ll i = l0; i <= r0; i++) {
    print(sst.query(i, i), "q!");
  }
  while (upper >= lower) {
    ll right = (lower + upper) / 2;
    ll left = 1;
    ll minindex = sst.query(left, r0);
    if (minindex < N) {
      lower = right;
      result = right;
    } else {
      upper = right;
    }
  }
  return 0;
}
struct aval {
  ll index;
  ll val;
};
int main() {
  ll N, K;
  cin >> N >> K;
  vector<aval> va(N);
  vector<aval> ia(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    cin >> v;
    va[i] = {i, v};
    ia[i] = {i, v};
  }
  sort(va.begin(), va.end(), [](aval p, aval q) { return p.val < q.val; });
  vector<ll> ssti(N, 0);
  for (ll i = 0; i < N; i++) {
    ssti[va[i].index] = i;
  }
  auto sst = ssegmenttree(N, -INF);
  for (ll i = 0; i < N; i++) {
  }
  vector<ll> vva(N);
  for (ll i = 0; i < N; i++) {
    vva[i] = va[i].val;
  }
  vector<ll> dp(N, 0);
  dp[N - 1] = 1;
  sst.update(ssti[N - 1], 1);
  for (ll i = N - 2; i >= 0; i--) {
    ll v = ia[i].val;
    ll left = lower_bound(vva.begin(), vva.end(), v - K) - vva.begin();
    ll right = upper_bound(vva.begin(), vva.end(), v + K) - vva.begin() - 1;
    ll ml = -INF;
    if (left < N && right >= 0) {
      ml = sst.query(left, right);
    }
    if (ml < 0 || ml >= N) {
      dp[i] = 1;
    } else {
      dp[i] = 1 + ml;
    }
    sst.update(ssti[i], dp[i]);
  }
  print(dp[0]);
}
