#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, N = 3e5 + 5;
long long dp[N];
map<pair<long long, long long>, long long> m;
long long find(long long i, long long x, long long k, vector<long long> &a) {
  if (i >= a.size()) return m[{i, x}] = 0;
  if (x == -1) {
    return m[{i, x}] = max(find(i + 1, a[i], k, a) + 1, find(i + 1, x, k, a));
  }
  if (abs(a[i] - x) > k) return m[{i, x}] = find(i + 1, x, k, a);
  return m[{i, x}] = max(find(i + 1, a[i], k, a) + 1, find(i + 1, x, k, a));
}
long long solve() {
  memset(dp, 0, sizeof(dp));
  long long n, k, ans = 0;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = (long long)0; i < n; i++) cin >> a[i];
  return find(0, -1, k, a);
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << solve() << '\n';
}
