#include <iostream>
#include <list>

struct val {
	int number;
	int times_hit;
};
	
int main(int argc, char* argv[]) {
	
	int n, k;
	int item;
	std::cin >> n;
	std::cin >> k;
	
	std::list<int> items;
	for (int i = 1; i <= n; i++) {
		std::cin >> item;
		items.push_back(item);
	}
	
	std::list<val> dupes;
	for (int& c1 : items) {
		
		for (int& c2 : items) {
			if (c1 == c2 && &c1 != &c2) {
				
				bool hasItem = false;
				
				for (val& c3 : dupes) {
					if (c3.number == c2) {
						c3.times_hit += 1;
						hasItem = true;
					}
				}
				
				if (!hasItem) {
					val i;
					i.number = c2;
					i.times_hit = 1;
					dupes.push_back(i);
				}
			}
		}
	}
	
	std::list<int> dupes2;
	for (val& c : dupes) {
		
		if (c.times_hit >= k) {
			dupes2.push_back(c.number);
		}
	}
	
	
	std::cout << dupes2.size() << std::endl;
	for (int& c : dupes2) {
		std::cout << c << " ";
	}
	
	std::cout << std::endl;
	
	return 0;
}