#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

int main()
{
    iostream::sync_with_stdio(false);
    int n, k;
    cin>>n>>k;
    int gadja[n*2+1]={0}, i, brojacMeta[n*2+1]={0};

    for(i=0; i<n; ++i)
    {
        cin>>gadja[i];
        ++brojacMeta[gadja[i]];
    }
    set<int> promena;
    set<int> :: iterator itr;
    for(i=0; i<n*2+1; ++i)
    {
        if(brojacMeta[gadja[i]]>=k)
        {
            promena.insert(gadja[i]);
        }
    }
    cout<<promena.size()<<"\n";
    for(itr=promena.begin(); itr!=promena.end(); ++itr)
    {
        cout<<*itr<<" ";
    }
    cout<<"\n";
    return 0;
}