#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  cout << t;
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
const int mod = 1000000007;
void io_set() {}
int n, m;
int a[300005], dp[300005];
int dfs(int idx, int k) {
  if (idx >= n) return 0;
  if (dp[idx] != -1) return dp[idx];
  if (abs(a[idx] - k) <= m) return 1 + dfs(idx + 1, a[idx]);
  return dp[idx] = max(dfs(idx + 1, a[idx + 1]), dfs(idx + 1, a[idx]));
}
void solve() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << dfs(0, a[0]);
}
signed main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
