#include <bits/stdc++.h>
int dp[300010];
int seq[300010];
int main() {
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  for (int i = 0; i < N; i++) scanf("%d", &seq[i]);
  dp[0] = 1;
  int res = 0;
  for (int i = 1; i < N; i++) {
    dp[i] = 1;
    for (int j = 0; j < i; j++) {
      if (seq[j] - seq[i] <= K && seq[j] - seq[i] >= -1 * K) {
        int tem = dp[j] + 1;
        if (tem > dp[i]) dp[i] = tem;
      }
    }
    if (dp[i] > res) res = dp[i];
  }
  printf("%d", res);
}
