#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double PI = acos(-1);
static const int INF = 1e9 + 7;
template <typename T>
void view(T e) {
  cout << e << endl;
}
template <typename T>
void view(const vector<T>& v) {
  for (const auto& e : v) {
    cout << e << " ";
  }
  cout << endl;
}
template <typename T>
void view(const vector<vector<T> >& vv) {
  for (const auto& v : vv) {
    view(v);
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<bool> seen(n);
  for (int i = 0; i < (n); ++i) seen[i] = false;
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    if (seen[i] == true) continue;
    int now = a[i];
    int cnt = 1;
    for (int j = i + 1; j < (n - 1); ++j) {
      if (abs(now - a[j]) <= k) {
        cnt++;
        a[j] = true;
        now = a[j];
      }
    }
    now = a[i];
    for (int j = i - 1; j >= 0; j--) {
      if (abs(now - a[j]) <= k) {
        cnt++;
        now = a[j];
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
