#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> dp(1, vector<int>(0));
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  dp[0].push_back(A[0]);
  int size = 1;
  for (int i = 1; i < N; i++) {
    for (int j = size - 1; j >= 0; j--) {
      int k = lower_bound(dp[j].begin(), dp[j].end(), A[i]) - dp[j].begin();
      if (k == 0) {
        k = 1;
      }
      int k2 = upper_bound(dp[j].begin(), dp[j].end(), A[i]) - dp[j].begin();
      if (k2)
        if ((abs(A[i] - dp[j][k]) <= M) || (abs(A[i] - dp[j][k2]) <= M)) {
          int an = j + 1;
          cout << A[i] << dp[j][k - 1] << dp[j][k] << endl;
          if (an > (size - 1)) {
            vector<int> em(0);
            em.push_back(A[i]);
            dp.push_back(em);
            size++;
          } else {
            dp[an].push_back(A[i]);
            sort(dp.begin(), dp.end());
          }
          break;
        }
    }
  }
  cout << size - 1 << endl;
}
