#include <bits/stdc++.h>

using namespace std;

int main()
{
    unordered_map<int, int> mymap;
    int n, k, temp, brojac=0;
    string sol;
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin >> temp;
        mymap[temp]++;
    }
    for (auto x : mymap)
    {
        //cout << x.first << " " << x.second << endl;
        if(x.second >= k)
        {
            brojac++;
            sol+=to_string(x.first) + " ";
            //cout << x.first << " ";
        }
    }
    cout << brojac << endl << sol;
    return 0;
}