#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
using ll = long long;
const int mod = 998244353;
const ll inf = 1e18 + 1;
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  for (ll i = 0; i < (N); i++) {
    cin >> a[i];
  }
  vector<ll> dpl(N + 1, inf);
  vector<ll> dpr(N + 1, 0);
  dpl[0] = -inf;
  dpr[0] = inf;
  dpl[1] = a[0] - K;
  dpr[1] = a[0] + K;
  int l, r;
  int cen;
  for (int i = 1; i < N; i++) {
    l = 0;
    r = N;
    for (int j = N; j > 0; j--) {
      if (a[i] >= dpl[j] && dpr[j] >= a[i]) {
        dpl[j + 1] = min(dpl[j + 1], a[i] - K);
        dpr[j + 1] = max(dpr[j + 1], a[i] + K);
        break;
      }
    }
  }
  for (ll i = 0; i < (N + 1); i++) {
    if (dpl[i] == inf && dpr[i] == 0) {
      cout << i - 1;
      return 0;
    }
  }
}
