#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N, K, temp;
    map<int, int> Polja;
    cin >> N >> K;
    for(int i = 0; i < N; ++i)
    {
        cin >> temp;
        if(Polja.count(temp) > 0)
        {
            Polja[temp]++;
        }
        else
        {
            Polja[temp] = 1;
        }

    }

    vector<int> output;
    for(map<int,int>::iterator itr = Polja.begin(); itr != Polja.end(); ++itr)
    {
        if(itr->second >= K)
        {
            output.push_back(itr->first);
        }
    }

    cout << output.size() << "\n";
    for (int i = 0; i < output.size(); ++i)
    {
        cout << output[i] << " ";
    }

    return 0;
}