#include<iostream>
#include<stdio.h>
#include<queue>
#define MAX 1000005

using namespace std;

int a[MAX];

int main()
{
	queue <int> q;
	int n, k;
	int br = 0, x;
	cin >> n >> k;
	for(int i = 0;i < 2 * n + 2;i++)
		a[i] = 0;
	for(int i = 0;i < n;i++)
	{
		cin >> x;
		a[x + n]++;
		if(a[x + n] == k)
		{
			br++;
			q.push(x);
		}
	}
	cout << br << endl;
	while(!q.empty())
	{
		cout << q.front() << " ";
		q.pop();
	}
}