#include <bits/stdc++.h>

using namespace std;

map<int, int> koliko;
vector<int> vecR;

int main()
{
    int n, k; cin>>n>>k;

    for (int i=0; i<n; i++)
    {
        int x; cin>>x;
        koliko[x]++;
    }

    for (auto it=koliko.begin(); it!=koliko.end(); it++)
    {
        //cout<<it.first<<" "<<it.second<<endl;
        if (it->second>=k)
            vecR.push_back(it->first);
    }

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