#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5;
int main() {
  int n, k, a[maxn];
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cnt = 1, ans = 0;
  int b = a[0];
  for (int i = 0; i < n; i++) {
    int b = a[i];
    cnt = 1;
    for (int j = i + 1; j < n; j++) {
      if (abs(a[j] - b) <= k) {
        b = a[j];
        cnt++;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans;
}
