#include <bits/stdc++.h>
using namespace std;
using INT = long long;
using P = pair<int, int>;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  int now = 0;
  vector<int> skip;
  for (int i = 0; i < n - 1; i++) {
    if (abs(a[now] - a[i + 1]) <= k) {
      now = i + 1;
      ans++;
    } else
      skip.push_back(i + 1);
  }
  int x = 0;
  for (int i = 0; i < skip.size(); i++) {
    int new_ans = 0;
    int new_now = skip[x];
    skip.erase(skip.begin() + x);
    for (int k = new_now; k < n - 1; k++) {
      if (abs(a[new_now] - a[k + 1]) <= k) {
        new_now = k + 1;
        new_ans++;
      }
    }
    x++;
    if (new_ans > ans) ans = new_ans;
  }
  cout << ans;
  return 0;
}
