#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 min(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 minleftl(lsegmenttree& lst, ll l0, ll r0, ll K, ll x) {
  ll left = l0;
  ll right = l0 + 1;
  for (ll i = 0; i < 100; i++) {
    ll maxval = lst.query(left, right);
    if (maxval >= x && maxval <= x + K) {
      if (right - left <= 1) {
        ll a = lst.query(left, left);
        if (a == maxval) {
          return left;
        } else {
          return right;
        }
      }
      left = left + (right - left) / 2;
    } else {
      right = left + (right - left) * 2;
      right = min(right, r0);
    }
  }
  return INF;
}
ll minlefts(ssegmenttree& sst, ll l0, ll r0, ll K, ll x) {
  ll left = l0;
  ll right = l0 + 1;
  for (ll i = 0; i < 100; i++) {
    ll minval = sst.query(left, right);
    if (minval <= x && minval >= x - K) {
      if (right - left <= 1) {
        ll a = sst.query(left, left);
        if (a == minval) {
          return left;
        } else {
          return right;
        }
      }
      left = left + (right - left) / 2;
    } else {
      right = left + (right - left) * 2;
      right = min(right, r0);
    }
  }
  return INF;
}
int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  auto lst = lsegmenttree(N, -INF);
  auto sst = ssegmenttree(N, INF);
  for (ll i = 0; i < N; i++) {
    lst.update(i, A[i]);
    sst.update(i, A[i]);
  }
  vector<ll> dp(N, 0);
  dp[N - 1] = 1;
  for (ll i = N - 2; i >= 0; i--) {
    ll minnext = min(minleftl(lst, i + 1, N - 1, K, A[i]),
                     minlefts(sst, i + 1, N - 1, K, A[i]));
    if (minnext == INF) {
      dp[i] = dp[i + 1];
    } else {
      dp[i] = max(dp[i + 1], 1 + dp[minnext]);
    }
  }
  print(dp[0]);
}
