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