#include <iostream>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	int niz[1000000];
	for (int i = 0; i < n; i++)
		cin >> niz[i];

	int dup[1000000];
	for (int i = 0; i < 1000000; i++)
		dup[i] = 0;

	int min = niz[0];
	for (int i = 0; i < n; i++)
		if (niz[i] < min)
			min = niz[i];
    int zam = 0;
    int res[1000000];
	if (min < 0)
	{
		for (int i = 0; i < n; i++)
			dup[niz[i] - min]++;
		for (int i = 0; i < n; i++)
			if(dup[niz[i] - min] >= k)
			{
			    res[zam] = niz[i];
				zam++;
				dup[niz[i] - min] = 0;
			}
	}
	else
	{
		for (int i = 0; i < n; i++)
			dup[niz[i]]++;
		for (int i = 0; i < n; i++)
			if (dup[niz[i]] >= k)
			{
			    res[zam] = niz[i];
				zam++;
				dup[niz[i]] = 0;
			}
	}

    cout<<zam<<endl;
    for(int i = 0; i < zam; i++)
        cout<<res[i]<<" ";
	return 0;
}