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