#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  x %= (long long)1e9 + 7;
  if (!x) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % (long long)1e9 + 7;
    y = y >> 1;
    x = (x * x) % (long long)1e9 + 7;
  }
  return res;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    int j, n, k, i;
    cin >> n >> k;
    vector<int> a(n);
    for (i = 0; i < n; i++) cin >> a[i];
    vector<int> dp(n, 0);
    dp[0] = 1;
    for (i = 1; i < n; i++) {
      dp[i] = 1;
      for (j = i - 1; j >= 0; j--) {
        if (abs(a[i] - a[j]) <= k) dp[i] = max(dp[i], 1 + dp[j]);
      }
    }
    cout << dp[n - 1] << " ";
  }
  return 0;
}
