#include <bits/stdc++.h>
using namespace std;

int n,a[2000005],k,in;
vector<int> out;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>in;
        if(in<0)
        {
            a[in+2*n+1]++;
            if(a[in+2*n+1]>=k)
            {
                out.push_back(in);
                a[in+2*n+1]=-999999999;
            }
        }
        else
        {
            a[in]++;
            if(a[in]>=k)
            {
                out.push_back(in);
                a[in]=-999999999;
            }
        }
    }
    cout<<out.size()<<"\n";
    for(auto i:out)
    {
        cout<<i<<" ";
    }
}