#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f;
const double pi = 3.1415926535897932384626;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int maxn = 3e5 + 5;
int n, k, a[maxn], dp[maxn], f[maxn];
int main() {
  n = read(), k = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  dp[1] = 1;
  int now = 1, ans = 0;
  for (int i = 2; i <= n; i++) {
    if (abs(a[i] - a[now]) <= k) {
      dp[i] = dp[now] + 1;
      now = i;
      ans = max(ans, dp[i]);
    }
  }
  f[2] = 1;
  now = 2;
  for (int i = 3; i <= n; i++) {
    if (abs(a[i] - a[now]) <= k) {
      f[i] = f[now] + 1;
      now = i;
      ans = max(ans, f[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
