#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int n, k, broj;
    cin >> n >> k;
    map <string,long long int> map1;
    long long int brojac = 0;
    vector <string> niz;

    for (long long int i = 0; i < n; i++)
    {
        cin >> broj;
        string tmp = to_string(broj);
        if(map1[tmp] == NULL)
            map1[tmp] = 1;
        else
            map1[tmp]++;

        if(map1[tmp] == k)
        {
            brojac++;
            niz.push_back(tmp)
        }

    }
    cout << brojac << endl;
    for(long long int i = 0; i < brojac; i++)
    {
        cout << niz[i] << " ";
    }


    return 0;
}