#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long temp;
  while (b > 0) {
    temp = a % b;
    a = b;
    b = temp;
  }
  return a;
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long power(long long x, long long b, long long m) {
  long long p = 1;
  while (b > 0) {
    if (b & 1) {
      p = p * x;
      p %= m;
    }
    b >>= 1;
    x *= x;
    x %= m;
  }
  return p % m;
}
void dbg(string s) { cout << s << endl; }
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<vector<long long>> op;
  vector<long long> temp{a[0]};
  op.push_back(temp);
  for (int i = 1; i < n; i++) {
    bool flag = false;
    for (int j = 0; j < op.size(); j++) {
      if (abs(op[j][op[j].size() - 1] - a[i]) <= k) {
        op[j].push_back(a[i]);
        flag = true;
      }
    }
    if (flag == false) {
      vector<long long> temp{a[i]};
      op.push_back(temp);
    }
  }
  long long ans = 0;
  for (int i = 0; i < op.size(); i++) {
    ans = max(ans, (long long)op[i].size());
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
