#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int main(void) {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = 1, now, end = n;
  for (long long i = 0; i < end; ++i) {
    now = a[i];
    long long t = 1;
    bool init = true;
    for (long long j = i + 1; j < n; ++j) {
      if (abs(now - a[j]) <= k) {
        ++t;
        now = a[j];
        if (init) {
          init = false;
          end = max(end, j);
          if (end == n) {
            end = j;
          }
        }
      }
    }
    ans = max(ans, t);
  }
  cout << ans;
}
