#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, result = 0;
  cin >> N >> K;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<bool> flag;
  flag.assign(N, false);
  for (int i = 0; i < N; i++) {
    int tmp = i, result_tmp = 0, index = 0;
    if (!flag[i]) {
      while (index < N) {
        if ((tmp != index) && abs(A[tmp] - A[index]) <= K) {
          result_tmp++;
          flag[index] = true;
          tmp = index;
          index++;
        } else {
          index++;
        }
      }
      if (result_tmp > result) {
        result = result_tmp;
      }
    }
  }
  cout << result << endl;
}
