#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
int N, K;
int main() {
  cin >> N >> K;
  vi A(N);
  for (int i = 0; i < (N); ++i) cin >> A[i];
  vvi dp(N + 1);
  int ans = 1;
  for (int i = 0; i < (N); ++i) {
    for (auto a : dp[ans - 1]) {
      if (abs(A[i] - a) <= K) {
        dp[ans].push_back(A[i]);
      }
    }
    if (dp[ans].size()) ans++;
    dp[0].push_back(A[i]);
  }
  cout << ans << endl;
  return 0;
}
