#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int N,K,INPUT;
    long long int counter = 0;
    vector <string> OUTPUT;
    scanf("%lld %lld",&N,&K);
    map <string,long long int> MyMap;

    for (long long int i = 0; i < N; i++)
    {
        scanf("%lld",&INPUT);
        string input = to_string(INPUT);

        if(MyMap[input] == '\0')
           MyMap[input] = 1;
        else
            MyMap[input]++;

        if(MyMap[input] == K)
        {
            counter++;
            OUTPUT.push_back(input);
        }

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



    return 0;
}