#include <bits/stdc++.h>

using namespace std;

int A[300100];
int B[300100];
int N, M;
int ANS;

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; ++i) {
		scanf("%d", A + i);
	}
	sort(A, A + M);
	int l = 0, p = 0;
	for (int i = 0; i < M; ++i) {
		if (A[l] == A[i]) {
			++p;
		} else {
			if (p >= N) {
				B[ANS] = A[l];
				++ANS;
			}
			p = 1;
			l = i;
		}
	}
	if (A[M - 2] == A[M - 1]) {
		++p;
	} else {
		if (p >= N) {
			B[ANS] = A[l];
			++ANS;
		}	
	}
	printf("%d\n", ANS);
	for (int i = 0; i < ANS; ++i) {
		printf("%d ", B[i]);
	}
	printf("\n");
}