#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
void files() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  fast();
  long long n, k;
  cin >> n >> k;
  vector<int> d(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  int ans = 0;
  vector<int> vis(n, 0);
  for (int i = 0; i < n; i++) {
    if (vis[i] == 1) {
      continue;
    }
    int k1 = 0, ls = d[i], j = i;
    while (j < n) {
      if (abs(d[j] - ls) <= k) {
        ls = d[j];
        k1++;
        vis[j] = 1;
      }
      j++;
    }
    ans = max(ans, k1);
  }
  cout << ans;
  return 0;
}
