# include <bits/stdc++.h>
# define flash ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
# define ff first
# define ss second
# define pb push_back
# define all(x) x.begin(), x.end()
# define allr(x) x.rbegin(), x.rend()
# define in insert
# define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)

typedef long long ll;
typedef double db;
typedef long double ld;
using namespace std;

const int N = 2e5 + 5;
const ll inf = 1e9 + 7;
const ll INF = 1e18;
const db pi = acos(-1.0);

int tt=1, n, m, a[N], ans;
map <int, int> mp;
set <int> s;
vector <int> v;

void solve(){
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		cin >> a[i];
	}
	sort(a + 1, a + m + 1);

	for(int i=1, j=1; i<m; ){
		while(a[i]==a[j]){
			j++;
		}
		if(j-i>=n){
			v.pb(a[i]);
		}i=j;
		
	}
	cout << v.size() << '\n';
	for (int i : v){
		cout << i << ' ';
	}
}
int main (){
	//file(s);
	flash;
	//cin >> tt;
	while (tt--){
		solve();
	}
	return 0;
}

