#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

static unordered_map<int, int> polja;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    	int n, k;
        	cin >> n >> k;
            	vector<int> momenti;
                	while (n--)
                    	{
                        		int koord;
                                		cin >> koord;
                                        		polja[koord]++;
                                                		if (polja[koord] == k)
                                                        			momenti.push_back(koord);
                                                                    	}
                                                                        	cout << momenti.size() << '\n';
                                                                            	for (auto polje : momenti)
                                                                                		cout << polje << ' ';
                                                                                        }