#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;
using ll = long long;

int main() {
	ll n, m;
	cin >> n >> m;
	set <int> stoimosti1;
	multiset <int> stoimosti2;
	vector <int> variants;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		stoimosti1.insert(a);
		stoimosti2.insert(a);
	}
	for (auto it : stoimosti1) {
		if (stoimosti2.count(it) >= n) {
			variants.push_back(it);
		}
	}
	cout << variants.size()<<"\n";
	for (int i = 0; i < variants.size(); i++) {
		cout << variants[i] << " ";
	}
}