#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void pp(T... args) {
  ((cout << args << " "), ...);
  cout << "\n";
}
void solve() {
  long long int n, k;
  rd(n, k);
  vector<long long int> dp(n, 1);
  vector<long long int> arr(n);
  for (long long int& v : arr) rd(v);
  for (long long int i = 1; i < n; i++) {
    for (long long int j = 0; j < i; j++) {
      if (abs(arr[i] - arr[j]) <= k) dp[i] = max(dp[i], 1ll + dp[j]);
    }
  }
  pp(*max_element(dp.begin(), dp.end()));
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  solve();
  return 0;
}
