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