#include <iostream>
typedef  long long ll;

using namespace std;

int main()
{
    ll n,k,i,j,m,ind=0,br=0;
    cin>>n>>k;
    ll A[n];
    for (i=0; i<n; ++i)
        cin>>A[i];
        if (A[i]!=1 || A[i]!=0) br++;
    if (br==0) {
        br=0;
        for (i=0; i<n; ++i) {
            if (A[i]==1) br++;
            if (br<=k) A[i]=-1;
            else break;
        }
    }
    else {

     for (i=0; i<k; ++i) {
        ind=0;
        for (j=0; j<n; ++j) {
            if (A[j]>A[j+1]) {
                for (m=j; m<n-1; ++m) { //pomeranje u levo
                    A[m]=A[m+1];
                }
                n--;
                ind=1;
            }
            if (ind) break;
        }
        if (ind==0) n--;
    }
    }
    for (i=0; i<n; ++i)
    {
        if (A[i]!=-1)
            cout<<A[i]<<" ";
    }
    return 0;
}