#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int* read(int n) {
	int* t = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", t + i);
	return t;
}

int main() {
	int n, k;
	cin >> n >> k;
	int* t = new int[2 * n + 1];
	for (int i = 0; i < 2 * n + 1; i++)
		t[i] = 0;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		t[a + n]++;
	}
	int sum = 0;
	for (int i = 0; i < 2 * n + 1; i++)
		sum += (t[i] >= k);
	cout << sum << endl;
	for (int i = 0; i < 2 * n + 1; i++)
		if (t[i] >= k)
			printf("%d ", i - n);
	delete[] t;
	return 0;
}