#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
const int INF = 2e9;
const int MOD = 1e9 + 7;
void Solve() {
  int n, k, res = 0, a;
  cin >> n >> k;
  vector<int> v(n);
  for (int &num : v) cin >> num;
  for (int i = 0; i < n - 1; ++i) {
    int cnt = 0, tmp = v[i];
    for (int j = i + 1; j < n; ++j) {
      a = abs(tmp - v[j]);
      if (a <= k) {
        ++cnt;
        tmp = v[j];
      }
    }
    res = max(res, cnt);
  }
  cout << res + 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Solve();
  return 0;
}
