#include <iostream>
#include <unordered_map>
using namespace std;

int main()
{
    int n, k, i, j = 0;
    cin >> n >> k;
    unordered_map<int, int> brojac; 
    int niz[n], brojevi[n];
    for(i=0; i < n; i++)
    {
        cin >> niz[i];
        brojac[i] = 0;
        brojac[-i] = 0;
    }
    for(i = 0; i < n; i++)
    {
        brojac[niz[i]]++;
        if(brojac[niz[i]] == k)
        {
            brojevi[j] = niz[i];
            j++;
        }
    }
    cout << j << endl;
    for(i = 0; i < j; i++) cout << brojevi[i] << " ";
    return 0;
}