#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
void solve() {
  long long i, j, n, m, k;
  cin >> n >> k;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    scanf("%lld", &j);
    v.push_back(j);
  }
  long long maxLen = 0;
  for (i = 0; i < n; i++) {
    vector<long long> ans;
    ans.push_back(v[i]);
    for (j = i + 1; j < n; j++) {
      if (abs(v[j] - ans.back()) <= k) ans.push_back(v[j]);
    }
    maxLen = max(maxLen, (long long)ans.size());
  }
  cout << maxLen;
}
int main() {
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
