#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<pair<long long, long long>> v;
  for (long long i = 0; i < N; i++) {
    long long ts = v.size();
    for (long long j = 0; j < ts; j++) {
      if (abs(v[j].second - A[i]) <= K) {
        v.push_back(make_pair(1 + v[j].first, A[i]));
      }
    }
    v.push_back(make_pair(1, A[i]));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  cout << v[0].first << endl;
}
