#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>

using namespace std;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long n,k;
    cin >> n >> k;
    long *a=(long*)calloc(2*n+1,sizeof(long));
    vector <long> v;
    for (long i=0;i<n;i++)
    {
        long d;
        cin >> d;
        if (a[d+n]==k) continue;
        ++a[d+n];
        if (a[d+n]==k) v.push_back(d);
    }
    long m=v.size();
    cout << m << "\n";
    for (long i=0;i<m;i++)
        cout << v[i] << " ";
    delete[] a;
    return 0;
}