#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;

    cin >> n >> k;

    map<int, int> m;

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

        cin >> a;

        if(m.find(a) == m.end())
        {
            m[a] = 1;
        }

        else
        {
            ++m[a];
        }
    }

    map<int, int>::iterator it;

    string s = "";
    int brojac = 0;

    for(it = m.begin(); it != m.end(); ++it)
    {
        if(it->second >= k)
        {
            if(brojac != 0)
            {
                s += " ";
            }

            s += to_string(it->first);
            brojac++;
        }
    }

    cout << brojac << "\n";
    cout << s << "\n";

    return 0;
}