#include <bits/stdc++.h>

using namespace std;

int main()
{
    vector <long long> a;
    long long n,k;
    cin>>n>>k;

    for (long long i = 0; i<n; i++)
    {
        long long pom;
        cin>>pom;
        a.push_back(pom);
    }

    vector <long long> b;
    long long p,br=0;
    for (long long i = 0; i<a.size(); i++)
    {
        p = 0;
        for (long long j = 0; j<a.size(); j++)
        {
            if (a[i] == a[j])
                p++;
        }
        if (p >= k)
        {
            b.push_back(a[i]);
        }

    }

    sort(b.begin(),b.end());
    for (long long i = 0; i<b.size(); i++)
    {
        for (long long j = 0; j<b.size(); j++)
        {
            if (b[i] == b[j])
            {
                b.erase(b.begin()+j);
            }
        }
    }

    cout<<b.size()<<endl;
    for (long long i = 0; i<b.size(); i++)
    {
        cout<<b[i]<<" ";
    }

    return 0;
}