#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int dp[n][n];
  bool used[n];
  memset(used, false, sizeof(used));
  for (int i = 0; i < n; i++) {
    memset(dp[i], 0, sizeof(dp[i]));
    if (used[i]) continue;
    dp[i][i] = 1;
    int last = i;
    used[i] = true;
    for (int j = i; j < n - 1; ++j) {
      if (a[last] - a[j + 1] <= k && a[last] - a[j + 1] >= -k) {
        dp[i][j + 1] = dp[i][j] + 1;
        last = j + 1;
        used[last] = true;
      } else
        dp[i][j + 1] = dp[i][j];
    }
  }
  int maxdp = 0;
  for (int i = 0; i < n; i++) {
    maxdp = max(maxdp, dp[i][n - 1]);
  }
  cout << maxdp << endl;
  return 0;
}
