#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < (n); ++i) cin >> a[i];
  int b[n];
  for (int i = 0; i < (n); ++i) b[i] = 1;
  int tmp = 1;
  for (int i = 1; i < n; ++i) {
    for (int j = i - 1; j >= 0; --j) {
      if (abs(a[i] - a[j]) <= k) {
        if (tmp == 1) ++tmp;
        if (b[j] > 0) {
          b[i] = b[j] + 1;
          if (b[j] > 1) {
            tmp = max(tmp, b[i]);
            break;
          }
        } else
          b[i] = 2;
      }
    }
  }
  sort(b, b + n);
  cout << b[n - 1] << endl;
  return 0;
}
