#include <bits/stdc++.h>
int n, k, a[300010], lst;
int f[300010][2];
template <class I>
inline I abs(I x) {
  return x >= 0 ? x : -x;
}
template <class I>
inline I max(I a, I b) {
  return a > b ? a : b;
}
int main(void) {
  scanf("%d%d", &n, &k), f[1][1] = 1;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  lst = a[1];
  for (int i = 2; i <= n; ++i) {
    f[i][0] = max(f[i - 1][1], f[i - 1][0]);
    f[i][1] = (abs(a[i] - lst) <= k) * (max(f[i - 1][1], f[i - 1][0]) + 1),
    lst = abs(a[i] - lst) <= k ? a[i] : lst;
  }
  printf("%d\n", max(f[n][1], f[n][0]));
  return 0;
}
