#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int a[N], n, m, dp[N];
int code(int id, int prev) {
  if (id >= n) return 0;
  if (dp[id] != -1) return dp[id];
  int s1, s2, s;
  if (abs(prev - a[id]) <= m) {
    s1 = 1 + code(id + 1, a[id]);
    s2 = code(id + 1, prev);
    s = max(s1, s2);
  } else
    s = code(id + 1, prev);
  return dp[id] = s;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int i, j, k, r, s, t, x, y;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << code(0, 0) << endl;
  return 0;
}
