#include <bits/stdc++.h>
using namespace std;
const int nax = 1e5;
int dp[nax];
bool sorter2(const pair<long int, long int> &a,
             const pair<long int, long int> &b) {
  return (a.second < b.second);
}
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  int a;
  vector<pair<int, int> > arr;
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr.push_back(make_pair(i, a));
  }
  sort(arr.begin(), arr.end(), sorter2);
  for (int i = 0; i < n; i++) {
    cout << arr[i].first << '-' << arr[i].second << endl;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      if ((arr[j].second < arr[i].second) &
          (abs(arr[j].first - arr[i].first) <= k)) {
        dp[i] = dp[j] + 1;
        break;
      }
    }
  }
  cout << dp[n - 1] + 1 << endl;
}
