#include <bits/stdc++.h>
using namespace std;
long long vis[300001];
int main() {
  long long i, j, k, n, z, cnt, ans = 0;
  cin >> n >> k;
  long long a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    if (vis[i] == 0) {
      vis[i] = 1;
      z = a[i];
      cnt = 1;
      for (j = i + 1; j < n; j++) {
        if (abs(a[j] - z) <= k) {
          z = a[j];
          vis[j] = 1;
          cnt++;
        }
      }
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}
