#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#define ll long long

using namespace std;

int main()
{
    ll n, k, x;
    map<ll, ll>m;
    cin >> n >> k;

    set<ll>s;

    for (ll i = 0; i < n; i++)
    {
        cin >> x;
        m[x]++;

        if (m[x] >= k)
            s.insert(x);
    }

    cout << s.size() << endl;

    for (auto i = s.begin(); i != s.end(); i++)
        cout << *i << " ";

    return 0;
}