#include<bits/stdc++.h>

using namespace std;

vector<int> niz;

struct node
{
    int n;
    node *nxt;
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    node *head;
    node *tmp;
    cin >> n >> k;
    int tk = k;
    bool h = false;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        if(a != 0 && a != 1)
          h = true;
        niz.push_back(a);
    }
    if(h)
    {
        cout << 1;
        int j = 0;
        int tr = 0;
        while(k > 0)
        {
            for(int i = 0;i  <= k;i++)
            {
                if(niz[i+j] < niz[tr])
                    tr = i+j;
            }
            /*for(int i = 0;i < niz.size();i++)
                cout << niz[i] << " ";
            cout << endl;
            cout << tr << endl;*/
            niz.erase(niz.begin()+j,niz.begin()+tr);
            //cout << j << " " << tr << endl;

            k = k - (tr-j);
            if(tr - j == 0)
                tr++;

            //else
                j = tr;


        }

    }
    else
    {
        int br = 0;
        for(int i = 0;i < niz.size();i++)
        {
            if(niz[i]==1 && br < k)
            {
                niz.erase(niz.begin()+i);
                i--;
                br++;
            }

        }
        /*for(int i = 0;i < niz.size();i++)
            cout << niz[i] << " ";
            cout << endl;
        cout << k - br << endl;*/
        if(k - br != 0)
            niz.erase(niz.begin(),niz.begin()+k-br);

    }
    for(int i = 0;i < niz.size();i++)
            cout << niz[i] << " ";
}

/*
10 3
1 1 0 1 0 1 1 0 0 1

*/