#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 30;
const long long INFL = 1LL << 60;
long long MOD = 998244353;
void pres(double A, long long x = 10) {
  cout << fixed << setprecision(x) << A << endl;
}
void BinarySay(long long x, long long y = 60) {
  for (long long i = 0; i < (y); i++) cout << (x >> (y - 1 - i) & 1);
  cout << 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];
    A[i]--;
  }
  vector<long long> ans(N, -1);
  vector<long long> left(N), right(N);
  vector<long long> pos(N);
  for (long long i = 0; i < (N); i++) pos[A[i]] = i;
  set<long long> rest;
  for (long long i = 0; i < (N); i++) rest.insert(i);
  for (long long i = 0; i < (N); i++) {
    left[i] = i - 1;
  }
  for (long long i = 0; i < (N); i++) right[i] = i + 1;
  long long turn = 1;
  while (rest.size()) {
    deque<long long> erased;
    long long M = *rest.rbegin();
    rest.erase(M);
    erased.push_back(pos[M]);
    ans[pos[M]] = turn;
    long long now = pos[M];
    for (long long i = 0; i < (K); i++) {
      if (left[now] == -1) break;
      now = left[now];
      ans[now] = turn;
      rest.erase(A[now]);
      erased.push_front(now);
    }
    now = pos[M];
    for (long long i = 0; i < (K); i++) {
      if (right[now] == N) break;
      now = right[now];
      ans[now] = turn;
      rest.erase(A[now]);
      erased.push_back(now);
    }
    long long first = erased[0];
    long long second = erased.back();
    if (left[first] != -1) right[left[first]] = right[second];
    if (right[second] != N) left[right[second]] = left[first];
    turn = 3 - turn;
  }
  for (long long i = 0; i < (N); i++) {
    cout << ans[i];
  }
  cout << endl;
}
int main() { solve(); }
