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