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