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