#include <iostream>
#include <algorithm>
#include <limits>

using namespace std;

typedef numeric_limits<streamsize> ignore_t;

int main() 
{
	int N{};
	int K{};
	
	scanf("%d %d\n", &N, &K);
	
	int* A = new int[N];
	int* B = new int[N];

	for (int i{}; i < N; ++i) 
	{
		cin >> A[i];
	}
	cin.ignore(ignore_t::max(), '\n');

	int b{0};
	for (int i{}; i < N; ++i) 
	{
		int br{1};
		for (int j{i+1}; j < N; ++j) 
		{
			if (A[i] == A[j]) 
			{
				if (++br == K) 
				{
					if (!b) 
						B[b++] = A[i];
					else 
					{
						for (int k{}; k < b; ++k)
						{
							if (A[i] == B[k])
								break;
							else
								B[b++] = A[i];
						}
					}
				}
			}
		}
	}

	cout << b << '\n';
	for (int i{}; i < b; ++i) 
	{
		cout << B[i] << ' ';
	}

	cin.clear();
	cin.ignore(ignore_t::max(), '\n');
	cin.ignore();

	return 0;
}