#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	long long c;
	int x = 0;
	vector<long long> vektorik(m);
	while (x < m) {
		cin >> c;
		vektorik[x] = c;
		x++;
	}

	sort(vektorik.begin(), vektorik.end());

	set<long long> answers;
	int count = 1;
	long long answer;

	if (n == 1 && m == 1) {
		cout << 1 << endl;
		cout << c;
	}
	else if (n == 1 && m != 1) {
		for (int i = 0; i < m; i++) {
			answers.insert(vektorik[i]);
		}
		cout << answers.size() << endl;

		multiset <long long> ::iterator counter = answers.begin();

		for (int i = 1; counter != answers.end(); i++, counter++) {
			cout << *counter << " ";
		}
	}
	else {
		for (int i = 0; i < m-1; i++) {
			if (vektorik[i] == vektorik[i + 1]) {
				count += 1;
				answer = vektorik[i];
			}
			else {
				if (count >= n) {
					answers.insert(answer);
				}
				count = 1;
				answer = vektorik[i];
			}
		}
		if (count >= n) {
			answers.insert(answer);
		}

		cout << (long long)answers.size() << endl;

		
		multiset <long long> ::iterator counter = answers.begin();

		for (int i = 0; counter != answers.end(); i++, counter++) {
			cout << *counter << " ";
		}
	}
}