#include <iostream>
using namespace std;
int main()
{
    int n, k, br=0;
    cin>>n>>k;
    int a[n];
    for (int i=0; i<n; i++)
        cin>>a[i];
    int b[2*n+1],c[2*n+1] ;
    for (int i=-n; i<=n; i++)
        {
            b[i]=0;
            c[i]=0;
        }
    for (int i=0; i<n; i++)
        b[a[i]]++;
    for (int i=-n; i<=n; i++)
    {
        if (b[i]>=k)
            {
                c[i]=1;
                br++;
            }
    }
    cout<<br<<endl;
    for (int i=-n; i<=n; i++)
    {
        if (c[i]==1)
            cout<<i<<" ";
    }
}