#include <iostream>
#include <string>
using namespace std;

int negf(int res[], int brneg, int neg[],int k) {
	int sum = 0;
	for (int i = 0; i < brneg - 1; i++) {
		int br = 1;
		for (int j = i + 1; j < brneg; j++) {
			if (neg[i] == neg[j])
				br++;;
		}
		bool nema = true;
		for (int y = 0; y < sum; y++)
			if (res[y] == neg[i])
				nema = false;

		if (br >= k && nema) {
			res[sum] = neg[i];
			sum++;
		}
	}
	return sum;
}

int main()
{
	int n, k;
	cin >> n >> k;
	int niz[n];
	int res[n];
	int sum;

	int brpoz = 0;
	int brneg = 0;
	int poz[n];
	int neg[n];
	
	for (int i = 0; i < n; i++) {
		cin >> niz[i];
		if (niz[i] >= 0) {
			poz[brpoz] = niz[i];
			brpoz++;
		}
		else {
			neg[brneg] = niz[i];
			brneg++;
		}
	}
	bool q = false;
	int sum2;
	int res2[n];
	if (n < k)
		cout << 0;
	else if (brpoz < k)
		sum = negf(res, brneg, neg, k);
	else if (brneg < k)
		sum = negf(res, brpoz, poz, k);
	else {
		q = true;
		sum = negf(res, brneg, neg, k);
		sum2= negf(res2, brpoz, poz, k);
	}
	cout << sum<<endl;
	for (int i = 0; i < sum; i++) {
		cout << res[i] << ' ';
	}
	if (q) {
		for (int j = 0; j < sum2; j++) {
			cout << res2[j] << ' ';
		}
	}
}