#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
int dp[maxn];
int a[maxn];
void solved() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    int m = 0;
    for (int j = 1; j < i; j++) {
      if (abs(a[j] - a[i]) <= k) {
        m = max(m, dp[j]);
      }
    }
    dp[i] = m + 1;
  }
  cout << dp[n] << endl;
}
int main() {
  solved();
  return 0;
}
