#include <bits/stdc++.h>
using namespace std;
long long a[300005];
unordered_map<string, long long> dp;
long long n, k;
long long sol(long long i, long long last) {
  if (i == n + 1) return 0;
  string key = to_string(i) + "_" + to_string(last);
  long long &ret = dp[key];
  if (ret) return ret;
  ret = sol(i + 1, last);
  if (abs(a[i] - a[last]) <= k) {
    ret = max(ret, sol(i + 1, i) + 1);
  }
  return ret;
}
void solve() {
  cin >> n >> k;
  a[0] = 600005;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  cout << sol(1, 1);
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long T = 1;
  while (T--) solve();
  return 0;
}
