#include <bits/stdc++.h>
using namespace std;
bool in_K(long long int x, long long int y, long long int K) {
  if (-K <= x - y && x - y <= K) {
    return true;
  } else {
    return false;
  }
}
int main() {
  long long int N, K;
  cin >> N >> K;
  vector<long long int> A(N);
  for (long long int i = 0; i < N; i++) {
    cin >> A[i];
  }
  if (N == 1) {
    cout << 1 << endl;
  } else {
    long long int count = 1;
    long long int ans = 1;
    do {
      for (long long int i = 0; i < N - 1; i++) {
        if (in_K(A[i], A[i + 1], K)) {
          count++;
        } else {
          break;
        }
      }
      if (ans < count) {
        ans = count;
      }
      count = 1;
    } while (next_permutation(A.begin(), A.end()));
    cout << ans << endl;
  }
}
