#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[300005], dp[300005];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  dp[1] = 1;
  for (int i = 1; i <= n; ++i) {
    int pos = 0;
    for (int j = i - 1; j >= 1; --j) {
      if (abs(a[i] - a[j]) <= k) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
  }
  int mx = 0;
  for (int i = 1; i <= n; ++i) {
    mx = max(mx, dp[i]);
  }
  printf("%d\n", mx);
  return 0;
}
