#include <bits/stdc++.h>

using namespace std;

void pojavlivanje(int a[], int n, int k)
{
    vector<bool> vidjen(n, false);
    vector<int> v;
    int br=0;
    for (int i = 0; i < n; i++)
    {

        if (vidjen[i] == true)
            continue;

        int count = 1;
        for (int j = i + 1; j < n; j++)
        {
            if (a[i] == a[j])
            {
                vidjen[j] = true;
                count++;
            }
        }
        if(count >= k)
        {
            br++;
            v.push_back(a[i]);
        }
    }
    cout << br << endl;
    for(int i=0;i<v.size();i++)
    {
        cout << v[i] << " ";
    }
}

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0; i<n; i++)
        cin >> a[i];
    pojavlivanje(a, n,k);
    return 0;
}