#include <bits/stdc++.h>
using namespace std;
int n, k;
int v[300010], dp[300010];
int f(int pos, int ult) {
  if (pos == n) return 0;
  int &ans = dp[pos];
  if (ans == -1) {
    if (abs(v[pos] - v[ult]) <= k) ans = f(pos + 1, pos) + 1;
    ans = max(ans, f(pos + 1, ult));
  }
  return ans;
}
void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> v[i];
  memset(dp, -1, sizeof dp);
  cout << f(0, 0) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
