#include <bits/stdc++.h>
using namespace std;
long long int binpow(long long int a, long long int b) {
  if (a == 0) return 0;
  if (b == 0) return 1;
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b = b >> 1;
  }
  return ans;
}
template <typename T>
T Min(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T Max(T a, T b) {
  return a > b ? a : b;
}
int n, k;
int sol(int i, vector<int> &a, vector<int> &dp, vector<int> &mn,
        vector<int> &mx) {
  if (dp[i] != 0) return dp[i];
  if (i >= n) return 0;
  if (i + 1 == n) return 1;
  if (a[i] + k < mx[i] && a[i] - k > mn[i]) return 1;
  for (int j = i + 1; j < n; ++j) {
    if (a[i] + k >= a[j] && a[i] - k <= a[j])
      dp[i] = max(dp[i], 1 + sol(j, a, dp, mn, mx));
  }
  return dp[i];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<int> mn(n + 1, INT_MAX), mx(n + 1, INT_MIN), dp(n + 1, 0);
  for (int i = n - 2; i >= 0; --i) {
    mn[i] = min(mn[i + 1], a[i + 1]);
    mx[i] = max(mx[i + 1], a[i + 1]);
  }
  cout << sol(0, a, dp, mn, mx) << '\n';
  return 0;
}
