#include <bits/stdc++.h>
using namespace std;
const long long int dx4[4] = {0, 1, 0, -1};
const long long int dy4[4] = {-1, 0, 1, 0};
const long long int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const long long int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
vector<string> vec_splitter(string s) {
  for (char& c : s) c = c == ',' ? ' ' : c;
  stringstream ss;
  ss << s;
  vector<string> res;
  for (string z; ss >> z; res.push_back(z))
    ;
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) long long int idx) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, long long int idx, Head H, Tail... T) {
  if (idx > 0) cerr << ", ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, T...);
}
long long int N, K;
const long long int MAXN = 3e5 + 5;
vector<long long int> A(MAXN);
long long int memo[MAXN][2];
long long int dp(long long int id, bool taken, long long int prev) {
  if (id == N) {
    return 0;
  }
  auto& res = memo[id][taken];
  if (res != -1) {
    return res;
  }
  res = -9e12;
  if (prev == -1) {
    res = max(res, dp(id + 1, true, A[id]) + 1);
  } else {
    if (abs(prev - A[id]) <= K) {
      res = max(res, dp(id + 1, true, A[id]) + 1);
    }
  }
  res = max(res, dp(id + 1, false, prev));
  return res;
}
void solve() {
  memset(memo, -1, sizeof(memo));
  cin >> N >> K;
  for (long long int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  cout << dp(0, 0, -1);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int T = 1;
  for (long long int i = 1; i <= T; ++i) {
    solve();
  }
  return 0;
}
