#include <bits/stdc++.h>

using namespace std;

int main()
{
    int i,j,n,k,p,r=0,q;
    cin>>n>>k;
    vector<int> V(n);
    vector<int> A;
    for(i=0;i<n;i++)cin>>V[i];
    sort(V.begin(),V.end());
    for(i=0;i<n;i++)
    {
        p=1;
        while(V[i]==V[i+1])
        {
            p++;
            i++;
        }
        if(p>=k)
        {
            r++;
            A.push_back(V[i]);
        }

    }
    cout<<r<<endl;
    for(i=0;i<A.size();i++)cout<<A[i]<<" ";
    return 0;
}