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

using namespace std;

int main(){
	int n, k, b;
    int count=0;
	int *niz;
    vector<int> v;


	scanf("%d%d", &n, &k);
	niz = new int[2*n+1];

    for(int i = 0; i<2*n+1; i++)
        niz[i] = 0;

    for(int i = 0; i<n; i++){
        scanf("%d", &b);
        niz[b+n]++;
        if(niz[b+n]==k){
            count++;
            v.push_back(b);
        }

    }
    printf("%d\n", count);
    for(int i = 0; i<v.size(); i++)
        printf("%d ", v[i]);
	return 0;
}