#include <iostream>

#define tip int

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    tip n, k, len = 0, temp;

    cin >> n >> k;

    tip niz[n - k];
    if (k == 1 && false){
        for(tip i = 0; i < n; ++i){
            cin >> temp;
            if (len == 0){
                niz[len] = temp;
                ++len;
            }
            else if (k != 0 && temp < niz[len - 1]){
                tip counter = 0;
                while (k != 0 && len - counter > 0 && niz[len - counter - 1] > temp){
                    --k;
                    ++counter;
                }
                len = len - counter;
                niz[len] = temp;
                ++len;
            }
            else{
                niz[len] = temp;
                ++len;
            }
        }

        for(tip i = 0; i < len - k; ++i){
            cout << niz[i] << " ";
        }
    }
    else{
        tip temp;
        for (tip i = 0; i < n; ++i){
            cin >> temp;
            if (k == 0 || temp == 0){
                cout << temp << " ";
            }
            else if (temp == 1 && k != 0){
                --k;
            }
        }
    }
    return 0;
}