#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const long long mod = 998244353;
const long long INF = 1LL << 60;
int main() {
  int n, k;
  cin >> n >> k;
  int ans = n;
  int a = 0;
  int s = 0;
  int q = 0;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (int j = 0; j < n; j++) {
    s = j;
    for (int i = s + 1; i < n; i++) {
      if (abs(A[i] - A[s]) <= k) {
        ans -= a;
        a = 0;
        s = i;
        continue;
      }
      a++;
    }
    ans -= a;
    q = (q, ans);
    ans = n;
    if (q > n - k - 1) break;
  }
  cout << q << "\n";
}
