#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, i, j, max_val = -1;
  cin >> N >> K;
  vector<int> arr(N);
  vector<int> ans(N, 1);
  for (i = 0; i < N; i += 1) {
    cin >> arr[i];
  }
  for (i = 0; i < N; i += 1) {
    for (j = i - 1; j >= 0; j -= 1) {
      if (abs(arr[i] - arr[j]) <= K) {
        ans[i] = max(ans[i], ans[j] + 1);
      }
    }
    max_val = max(ans[i], max_val);
  }
  cout << max_val << endl;
}
