#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define MAXN 1000000 + 7

int lista[MAXN];

int main() {
    int n;

    cin>>n;
    int k ;
    //cout<<"unesi k"<<endl;
    cin>>k;
    int a;
    vector<int> g1;
    for (int h=0;h<n;h++)
    {
        //cout<<"unesi br"<<endl;
        cin>>a;
        lista[h]=a;
    }

    int index=1;
    sort(lista, lista + n);
    int kk = lista[0];
    int brojac = 1;

    for (int i = 1; i < n; i++)
    {
        if(kk != lista[i])
        {
            if(brojac >= k)
            {
                g1.push_back(kk);
            }
            kk = lista[i];
            brojac = 1;
        }
        else
        {
            brojac++;
        }
    }

    if(brojac >= k)
    {
        g1.push_back(kk);
    }

    cout<< g1.size() << endl;
    int sz = g1.size();
    for(int i=0; i < sz; i++)
    {
        cout << g1[i] << ' ';
    }
    return 0;
}