#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (int i = 0; i < v.size(); i++) {
    if (i) os << ", ";
    os << v[i];
  }
  os << "}";
  return os;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> dp(n, 0);
  vector<int> last(n, 0);
  dp[0] = 1;
  last[0] = 0;
  for (int i = 1; i < n; i++) {
    dp[i] = dp[i - 1];
    last[i] = i - 1;
    for (int j = i - 1; j >= 0; j--) {
      if (abs(a[j] - a[i]) > k) continue;
      if (last[j] == j) {
        if (dp[i] < dp[j] + 1) {
          dp[i] = dp[j] + 1;
          last[i] = i;
        }
        break;
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}
