#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long lis[n];
  for (long long i = 0; i < n; i++) lis[i] = 1;
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < i; j++) {
      if (abs(a[j] - a[i]) <= k && lis[i] < lis[j] + 1) lis[i] = lis[j] + 1;
    }
  }
  long long ans = *max_element(lis, lis + n);
  cout << ans << endl;
}
