#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n), dp(n, 1);
  for (auto i = 0; i < n; i++) cin >> a[i];
  dp[0] = 1;
  for (auto i = 1; i < n; i++) {
    for (auto j = i - 1; j >= 0; j--) {
      if (abs(a[j] - a[i]) <= k) dp[i] = max(dp[j] + 1, dp[i]);
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}
