#include <bits/stdc++.h>
using namespace std;
vector<int> G[300010];
int dp[300010];
int dfs(int x, int p = -1) {
  if (dp[x] != -1) return dp[x];
  int ret = 0;
  for (auto to : G[x]) {
    if (to == p) continue;
    ret = max(ret, dfs(to)) + 1;
  }
  return dp[x] = ret;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  multiset<pair<int, int> > st;
  int a[300010];
  for (int i = 0; i < N; i++) cin >> a[i];
  st.insert({2000000000, -1});
  for (int i = 0; i < N; i++) {
    while (st.size()) {
      auto itr = st.lower_bound({a[i] - K, 0});
      int num = itr->first;
      int idx = itr->second;
      if (num <= a[i] + K) {
        G[idx].push_back(i);
        st.erase(itr);
      } else {
        break;
      }
    }
    st.insert({a[i], i});
  }
  for (int i = 0; i < N; i++) dp[i] = -1;
  int ans = 0;
  for (int i = 0; i < N; i++) ans = max(ans, dfs(i));
  cout << ans + 1 << endl;
  return 0;
}
