#include <iostream>
#include <vector>

using namespace std;

int main(){
	vector<int> ot;
	bool oy = false;
	int n, m, k, zn = 0, c = 0;
	cin >> n >> m;
	int arr[m];
	for(int i = 0; i < m; i++){
		cin >> arr[i];
	}
	for(int i = 0; i < m; i++){
		int smallInd = i;
		for(int j = i+1; j < m; j++){
			if(arr[j] < arr[smallInd]) smallInd = j;
		}
		int temp = arr[smallInd];
		arr[smallInd] = arr[i];
		arr[i] = temp;
	}
	for(int i = 0; i < m; i++){
		if(zn == arr[i])c++;
		else{
			zn = arr[i];
			c = 1;
		}
		if(!(ot.empty())){
			for(int j = 0; j != ot.size(); j++){
				if(ot[j] == zn) oy = 1;
				else oy = 0;
			}
		}
		if(zn == arr[i] && oy == 0 && c==n){
			k++;
			ot.push_back(arr[i]);
		}
		
	}
	cout << k << endl;
	for(int j = 0; j != ot.size(); j++){
			cout << ot[j] << ' ';
	}
}
