#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a;
  int ai;
  for (int i = 0; i < N; ++i) {
    cin >> ai;
    a.push_back(ai);
  }
  int *dp = (int *)malloc(sizeof(int) * (N + 2));
  memset(dp, 0, N + 2);
  dp[0] = 0;
  dp[1] = 1;
  for (int i = 2; i <= N; ++i) {
    int j;
    for (j = i - 1; j > 0; --j) {
      if (abs(a[i - 1] - a[j - 1]) <= K) break;
    }
    dp[i] = max(dp[i - 1], dp[j] + 1);
  }
  cout << dp[N] << endl;
  return 0;
}
