#include <bits/stdc++.h>
using namespace std;
using P = pair<int, long long>;
const long long inf = 1000000000007;
const int mod = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> ans(n, 1);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 1; i < (n); ++i) {
    int val = a[i];
    for (int j = i - 1; j >= 0; j--) {
      if (abs(val - a[j]) <= k) {
        ans[i] += ans[j];
        break;
      }
    }
  }
  vector<int> rans(n, 1);
  for (int i = n - 2; i >= 0; i--) {
    int val = a[i];
    for (int j = i + 1; j < n; j++) {
      if (abs(val - a[j]) <= k) {
        rans[i] += rans[j];
        break;
      }
    }
  }
  int mx = 0;
  for (int i = 0; i < (n); ++i) mx = max(ans[i], mx);
  for (int i = 0; i < (n); ++i) mx = max(rans[i], mx);
  cout << mx << endl;
  return 0;
}
