#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool compare(const pair<string, int> &a, const pair<string, int> &b) {
  return a.second < b.second;
}
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
vector<long long> pwx(10);
void cal(long long x) {
  pwx[0] = 1;
  for (long long i = 1; i < 10; i++) pwx[i] = x * pwx[i - 1];
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n), sz(n, 1);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long cnt = 1, lst = i;
    vector<long long> tmp;
    tmp.push_back(i);
    long long flag = 1;
    for (long long j = i + 1; j < n; j++) {
      if (abs(a[j] - a[lst]) <= k) {
        if (sz[j] > 1) {
          if (sz[lst] == 1) sz[lst] += sz[j];
          flag = 0;
          break;
        }
        lst = j;
        cnt++;
        tmp.push_back(j);
      }
    }
    if (!flag) continue;
    for (long long j = 0; j < tmp.size(); j++) {
      sz[tmp[j]] = max((long long)tmp.size() - j, sz[tmp[j]]);
    }
  }
  cout << *max_element(sz.begin(), sz.end()) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1, k = 1;
  while (t--) {
    solve();
    k++;
  }
}
