#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using graph = vector<vector<ll>>;
const long long inf = 2147483647;
const ll INF = 9223372036854775807;
signed main() {
  long long n, k;
  cin >> n >> k;
  long long res = 0;
  vector<long long> a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  for (ll j = 1; j < 100; j++) {
    long long ans = 0;
    long long l = a[n / j];
    for (ll i = 0; i < n; i++) {
      if (abs(l - a[i]) <= k) ans++, l = a[i];
    }
    res = max(res, ans);
  }
  cout << res << "\n";
  return 0;
}
