#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int dp[300300]{};
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) dp[i] = 1;
  int res = 0;
  int tmp = 0;
  for (int i = 1; i < N; ++i) {
    if (abs(A[i] - A[tmp]) <= K) {
      dp[i] = dp[tmp] + 1, dp[tmp];
      tmp = i;
    }
  }
  for (int i = 0; i < N; ++i) res = max(dp[i], res);
  cout << res << endl;
  return 0;
}
