#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long N = 2e6 + 5;
const long long INF = 1e18L;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
template <typename T, typename... Args>
inline string arrStr(T arr, long long n) {
  stringstream s;
  s << "[";
  for (long long i = 0; i < n - 1; i++) s << arr[i] << ",";
  if (n > 0) s << arr[n - 1];
  s << "]";
  return s.str();
}
inline void __trace_begin(long long line) { cerr << "#" << line << ": "; }
template <typename T>
inline void __trace_out_var(vector<T> val) {
  cerr << arrStr(val, val.size());
}
template <typename T>
inline void __trace_out_var(T* val) {
  cerr << arrStr(val, 10);
}
template <typename T>
inline void __trace_out_var(T val) {
  cerr << val;
}
inline void __trace(vector<string>::iterator it) { cerr << '\n'; }
template <typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
  __trace_out_var(a);
  cerr << "; ";
  __trace(++it, args...);
}
long long ar[N];
long long dp[N][2];
long long k;
long long solve(long long pos, long long f, long long last, long long n) {
  if (pos == n) return 0;
  if (dp[pos][f] != -1) return dp[pos][f];
  long long ans = 0;
  if (abs(ar[pos] - last) <= k)
    ans = max(ans, 1 + solve(pos + 1, 1, ar[pos], n));
  else
    ans = max(ans, solve(pos + 1, 0, last, n));
  return dp[pos][f] = ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long T = 1;
  while (T--) {
    long long n;
    cin >> n >> k;
    for (long long i = 0; i < n; i++) {
      cin >> ar[i];
      dp[i][0] = -1;
      dp[i][1] = -1;
    }
    cout << solve(0, 0, 0, n);
  }
  return 0;
}
