#include <bits/stdc++.h>
using namespace std;
int dp[300001];
bool checked[300001];
int solve(int cur, const vector<int> &next) {
  if (checked[cur]) return dp[cur];
  if (next[cur] == -1) return 1;
  checked[cur] = true;
  return dp[cur] = solve(next[cur], next) + 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  vector<int> next(n, -1);
  for (long long i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (abs(a[i] - a[j]) <= k) {
        next[i] = j;
        break;
      }
    }
  }
  int ret = 0;
  for (long long i = 0; i < next[0]; ++i) {
    ret = max(ret, solve(i, next));
  }
  cout << ret << endl;
  return 0;
}
