#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 77;
long long A[N], vis[N];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; ++i) {
    cin >> A[i];
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    if (vis[i]) continue;
    vector<long long> v;
    v.push_back(A[i]);
    vis[i] = 1;
    for (long long j = i + 1; j < n; ++j) {
      if (abs(A[j] - v.back()) <= k) {
        vis[j] = 1;
        v.push_back(A[j]);
      }
    }
    ans = max(ans, (long long)v.size());
  }
  cout << ans << '\n';
  return 0;
}
