#include <iostream>

using namespace std;

int main()
{

    unsigned long long int k, n, s=0, s1;

    cin >> n >> k;

    long long int a[n], b[n] = {0}, x[n];

    for (unsigned long long int i=0; i<n; ++i)
    {
        cin >> a[i];
    }

    for (unsigned long long int i=0; i<n; ++i)
        for (unsigned long long int j=0; j<n; ++j)
        {
            if (a[i] == a[j])
            {
                b[i] += 1;
            }
        }

    for (unsigned long long int i=0; i<n; ++i)
    {
        if (b[i] >= k)
        {
            x[s] = a[i];
            s += 1;
        }

    }
    s1 = s;

    for (unsigned long long int i=0; i<s; ++i)
        for (unsigned long long int j=i+1; j<s;)
        {
            if (x[i] == x[j])
            {
                for (int l=j; l<s1; l++)
                {
                        x[l] = x[l+1];
                }
                s--;
            }
            else j++;
        }

    cout << s << "\n";
    for (int i=0; i<s; ++i)
        cout << x[i] << " ";
        
    return 0;
}