#include <bits/stdc++.h>
using LL = long long;
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  int ans = 0;
  int temp = 0;
  vector<int> Dp(N + 1, 0);
  Dp[1] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      if (abs(A[i] - A[j]) <= K) {
        Dp[j] = max(Dp[j], Dp[i] + 1);
      }
    }
  }
  cout << Dp[N] << endl;
  return 0;
}
