#include <iostream>
#include <vector>

using namespace std;

int getIndex(int numOfEl, int point) {
    if(point<0)
        return (numOfEl)+(point*(-1));
    else
        return point;
}

int main() {
    int n, k;

    cin>>n;
    cin>>k;

    vector<int> a(2*n+100);
    vector<int> result(2*n+100, 0);
    int resultCounter = 0;

    for(int i=0; i<n; i++) {
        int el;

        cin>>el;
        int index = getIndex(n,el);
        a[index]++;

        if(a[index]==k)
            result[resultCounter++]=el;
    }

    cout<<resultCounter<<endl;
    for(int i=0; i<resultCounter; i++) {
        cout<<result[i]<<" ";
    }

    return 0;
}