    /*
Muqalzhar taui
*/
#include <bits/stdc++.h>
#include <iomanip>
   
#define ll long long
#define pb push_back
#define F first
#define S second
#define nl '\n'
#define all(x) x.begin(), x.end()
   
const int N = 3e5 + 7;
const int modd = 1e9 + 7;
const int INF = 1e9 + 7;
const double pi = 3.141592653589793238462643383279502884197;
using namespace std;

ll n, m; 
ll a[N];
void solve(){
	cin >> n >> m;
	map <ll, ll> mp;
	vector <ll> ans;
	for(int i = 1; i <= m; i++){
		cin >> a[i];
		mp[a[i]]++;
		if(mp[a[i]] == n) ans.pb(a[i]);
	}
	cout << ans.size() << nl;
	for(auto to : ans) cout << to << " ";
    return;
} 
   
int main(){
    // freopen("pails.in", "r", stdin);
    //  freopen("pails.out", "w", stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
      
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}