#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    long long n,k;
    cin>>n>>k;
    long long f[n],s[n][2]={10000000000},x[n]={10000000000};
    for (long long  i=0;i<n;i++)
    {
        cin>>f[i];
    }

    long long l,r=0,j,c,p=0;
    sort(f,f+n);
    l=f[0];
    x[0]=l;
    for (long long i=0;i<n;i++)
    {
        if (f[i]>l)
        {
            r++;
            x[r]=f[i];
            l=f[i];
        }
    }
    s[0][0]-=10000000000;
    c=x[r];
    j=x[p];
    while (j<=c+1)
    {
        for (long long i=0;i<n;i++)
        {
            if (f[i]==j)
            {
                s[p][0]++;
                s[p][1]=j;
            }
        }
        p++;
        if (j==c)
            break;
        j=x[p];

    }


    long long z=0;
    for (long long i=0;i<p;i++)
    {
        if (s[i][0]>=k)
            z++;
    }
    cout<<z<<endl;

    for (long long i=0;i<p;i++)
    {
        if (s[i][0]>=k)
            cout<<s[i][1]<<" ";
    }
    return 0;
}