#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    map<int,int> a;
    vector<int> v;

    int n,k;
    cin >> n >> k;

    for(int i = 0; i < n; i++) {
        int m;
        cin >> m;
        if(a.find(m) == a.end())
            a[m] = 1;
        else
            a[m] = a[m] + 1;

        if(a[m] == k)
            v.push_back(m);
    }

    cout << v.size() << endl;
    for(int i = 0; i < v.size(); i++) {
        if(i > 0)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
    return 0;
}