#include <iostream>

using namespace std;
int main()
{
    long int n,k;
    cin >> n >> k;
    int a[n], b[n];
    for (int i = 0;i<n;i++) cin >> a[i];
    int d = 0, x = 0, m = 0;
    for (int i = -n;i<n+1;i++)
    {
        for(int j = 0;j<n;j++)
        {
            if(i==a[j]) x++;
        }
        if(x>=k)
        {
            d++;
            b[m]=i;
            m++;
        }
        x=0;
    }
    cout<<d<<endl;
    for(int i = 0;i<d;i++)
    {
        cout<<b[i]<<" ";
    }
    return 0;
}