#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> num(300000);
  for (int i = 0; i < n; i++) {
    if (num[i] != 0) continue;
    int m = a[i];
    int cnt = 1;
    for (int j = i + 1; j < n; j++) {
      if (abs(a[j] - m) <= k) {
        cnt++;
        m = a[j];
      }
    }
    for (int j = i; j < n; j++) {
      if (abs(a[j] - m) <= k) {
        num[j] = cnt;
        m = a[j];
        cnt--;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, num[i]);
  }
  cout << ans << endl;
}
