#include <bits/stdc++.h>
using namespace std;
/*
<<<<It's never too late for a new beginning in your life>>>>
Today is hard
  tomorrow will worse
  but the day after tomorrow will be the sunshine..

HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............
Never give up  */

//The most CHALISHKANCHIK
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define rew(i, a, b) for(int i = a; i < b; i++)
#define wer(i, a, b) for(int i = b - 1; i >= a; i--)
#define int long long
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

void solve(){
	set<int> a;
	map<int,int> mp;
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int x;
		cin >> x;
		mp[x]++;
		if(mp[x]>=n)a.insert(x);
	}
	cout << a.size() << endl;
	for(auto i:a)cout << i << ' ';
}
main(){
	//~ ios
	int t = 1;
	//~ cin >> t;
	while(t--){
		solve();
	}
}










