#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (auto &it : A) cin >> it;
  vector<bool> visited(N, false);
  vector<int> cnt(N, 0);
  for (int i = 0; i < N; i++) {
    if (visited[i]) continue;
    int si = 1;
    cnt[i] = si;
    int prev = A[i];
    for (int j = i + 1; j < N; j++) {
      if (visited[j]) continue;
      if (abs(A[j] - prev) <= K) {
        si++;
        cnt[j] = si;
        visited[j] = true;
        prev = A[j];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) ans = max(ans, cnt[i]);
  cout << ans << endl;
  return 0;
}
