#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    double n,k,tr=1,brojac=0;
    cin >> n >> k;
    vector<double> a(n);
    vector<double> b;
    for(double i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    for(double i=1;i<n;i++)
    {
        if(a[i]==a[i-1]) tr++;
        else
        {
            if(tr>=k)
            {
                brojac++;
                b.push_back(a[i-1]);
            }
            tr=1;
        }
    }
    if(tr>=k)
    {
        brojac++;
        b.push_back(a[n-1]);
    }
    cout << brojac << endl;
    for(double i=0;i<brojac;i++) cout << b[i] << " ";
    return 0;
}