#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n,k,brojac=0;
    cin >> n;
    vector<int> a(2*n+1);
    for(int i=0;i<=2*n;i++) a[i]=0;
    vector<int> b;
    cin >> k;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        a[x+n]++;
        if(a[x+n]==k)
        {
            brojac++;
            b.push_back(x);
        }
    }
    cout << brojac << endl;
    for(int i=0;i<brojac;i++) cout << b[i] << " ";
    return 0;
}