#include <bits/stdc++.h>

using namespace std;

void Preb(int a[], int n, int k, int suma)
{

    unordered_map<int, int> tab;

    for (int i = 0; i < n; i++)

    tab[a[i]]++;

    for (auto x : tab)
    {

        if(x.second >= k)
        {
        suma++;
        }

    }
            cout << suma << "\n";
    for (auto x : tab)
    {

        if(x.second >= k)
        {
        cout << x.first << " ";
        }
    }
}



int main()
{
    int i, c, k, suma;
    cin >> c;
    cin >> k;
    int a[c];
    suma = 0;
    for(i = 0; i < c; i++)
    {
        cin >> a[i];
    }
    int n = sizeof(a) / sizeof(a[0]);

    Preb(a, n, k, suma);
    return 0;
}