#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, k, a, b=0;
     cin >> n >> k;

     //int niz[2*n+1] = {0};
     vector<int> ispis;
     //vector<int> niz;
     map<int, int> mapa;

     for(int i=0; i < n; i++)
     {
        cin >> a;
        //niz.push_back(a);
        mapa[a]++;

     }
    for (const auto& elem : mapa)
    {
        if(elem.second >= k)
        {
            b++;
            ispis.push_back(elem.first);
        }
      //elem.first gives you the key (int)
      //elem.second gives you the mapped element (vector)
    }
     /*for(int i=0; i < 2*n+1; i++)
     {
         if(niz[i] >= k)
         {
             b++;
             ispis.push_back(i-n);
         }
     }*/

     cout << b << endl;

    for(int i=0; i < b; i++)
    {
        cout << ispis[i] << " ";
    }
    cout << endl;
    return 0;
}