#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tt = 1;
  while (tt--) {
    int n, k, i, mx = 1, j;
    cin >> n >> k;
    int a[n], dp[n];
    for (i = 0; i < n; ++i) cin >> a[i];
    dp[0] = 0;
    for (i = 1; i < n; ++i) {
      dp[i] = 1;
      for (j = 0; j < i; ++j) {
        if (abs(a[i] - a[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
      }
      mx = max(mx, dp[i]);
    }
    cout << mx;
  }
}
