#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,p;
    cin>> n>>k;
    vector<int> br;
    int s[2*n+1]={0};
    for(int i=0;i<n;i++)
        {
            cin>>p;
            s[p+n]++;
            if(s[p+n]==k)br.push_back(p);
        }
    cout<<br.size()<<endl;
    for(int i=0;i<br.size();i++)
        cout<<br[i]<<" ";
    return 0;
}