#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 3e5 + 5;
const int INF = 0x3f3f3f3f;
int a[MAXN];
bool vis[MAXN];
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(0);
  int N, K;
  cin >> N >> K;
  for (register int i = 1; i <= N; i++) cin >> a[i];
  vis[1] = true;
  int last = a[1];
  for (int i = 2; i <= N; i++) {
    if (fabs(a[i] - last) > K) {
      last = a[i];
      vis[i] = true;
    }
  }
  int maxNum = 0;
  for (int i = 1; i <= N; i++) {
    if (!vis[i]) break;
    int cnt = 1, last = a[i];
    for (int j = i + 1; j <= N; j++) {
      if (fabs(a[j] - a[last]) <= K) {
        cnt++;
        last = a[j];
      }
    }
    maxNum = max(cnt, maxNum);
  }
  cout << maxNum;
  return 0;
}
