#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, K;
vector<int> memo;
vector<int> A;
int search(int pos) {
  if (memo[pos] != -1) return memo[pos];
  int max_cnt = 0;
  for (int i = pos + 1; i < (int)(N); i++) {
    if (abs(A[i] - A[pos]) <= K) max_cnt = max(max_cnt, search(i));
  }
  return memo[pos] = (max_cnt + 1);
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  A.resize(N);
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  memo.resize(N, -1);
  int ans = 0;
  for (int i = 0; i < (int)(N); i++) {
    ans = max(ans, search(i));
  }
  cout << ans << endl;
  return 0;
}
