/*Lazy propagation 21
 *
 *
 * Imansoska228
 * Imancrush
 * Imantopchik
 * .*n*.
 * Author: Imansoska
**/
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define FF first
#define SS second
#define pb push_back
#define bp pop_back()
#define pf push_front
#define int long long
#define Imansoska ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl cout << "\n"
#define len(x) x.size()
//#define input cin 
//#define print cout
 
const int N = 1e5 + 13 ;
const int maxn= 1e6+100;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

vector <int> g;
int z[N*3];
int n , m;

signed main (/*Imansoska*/) {
	Imansoska
	// freopen("bfs.in","r",stdin);
	// freopen("bfs.out","w",stdout);
	cin >> m >> n;
	for ( int i=1; i<=n; i++ ) {
		cin >> z[i];
	}
	sort(z+1, z+n+1);
	int c=0;
	for ( int i=1; i<=n; i++ ) {
		if ( z[i]==z[i-1] ) {
			c++;
		}
		else {
			if ( c>=m ) {
				g.pb(z[i-1]);
			}
			c=1;
		}
	}
	if ( c>=m ) {
				g.pb(z[n]);
			}
	cout << g.size();
	endl;
	for ( int i=0; i<g.size(); i++ ) {
		cout << g[i] << " ";
	}
}