#include <bits/stdc++.h>

using namespace std;

map<long long,long long> mapa;  ///posle samo proveri jos jednom ogranicenja

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

    long long N,K;

    cin>> N >> K;
    long long res = 0;

    for(long long i = 0; i < N; i++)
    {
        long long meta;
        cin>>meta;
        mapa[meta]++;
    }

   map<long long,long long>::iterator it = mapa.begin();

   while (it != mapa.end())
   {
        long long meta = it->first;
        long long br_pogodaka = it->second;
        if(br_pogodaka >= K) res++;
        it++;
   }

   it = mapa.begin();
   cout<<res<<endl;

	while(it != mapa.end())
    {
        long long meta = it->first;
        long long br_pogodaka = it->second;
        if(br_pogodaka >= K) cout << meta <<" ";
        it++;
    }


    return 0;
}