#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 3e5 + 10;
int a[maxn];
int main(void) {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int maxx = 0;
  for (int i = 1; i <= n; i++) {
    if (maxx >= n - i) break;
    int cnt = 1;
    int tmp = i;
    for (int j = i + 1; j <= n; j++) {
      if (abs(a[tmp] - a[j]) <= k) {
        cnt++;
        maxx = max(maxx, cnt);
        tmp = j;
      }
    }
  }
  cout << maxx << endl;
  return 0;
}
