#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<stack<int>> vec(1);
  vec[0].push(a[0]);
  for (int i = 1; i < n; ++i) {
    bool flag = true;
    for (int j = 0; j < vec.size(); ++j) {
      int top = vec[j].top();
      if (top - k <= a[i] && a[i] <= top + k) {
        vec[j].push(a[i]);
        flag = false;
      }
    }
    if (flag) {
      stack<int> tmp;
      tmp.push(a[i]);
      vec.push_back(tmp);
    }
  }
  int ans = 0;
  for (int i = 0; i < vec.size(); ++i) {
    ans = max(ans, (int)vec[i].size());
  }
  cout << ans << endl;
}
