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