#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC target("avx,avx2,fma")

#define int long long
#define damkk ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) ;
#define pb push_back
#define sz size()
#define F first
#define S second
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
#define all(s) (s).begin(),(s).end()
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yes cout << "Yes\n";
#define no cout << "No\n";

using namespace std ;

const int MaxN = 100010;
const int inf = 1e9 + 99;
const int MOD = 1e9 + 7 ;
const long double eps = 1e-6;

int binpow(int a , int b){
	if(b == 0){
		return 1;
	}
	if(b % 2 == 1){
		return binpow(a , b - 1) * a % MOD;
	}
	else{
		int val = binpow(a , b / 2);
		return val * val % MOD;
	}
}

void solve(){
	 int n , m;
    cin >> n >> m;
    map<int , int> mp;
  int a[m + 3];
  vector<int> v;
  for(int i = 0 ; i<m;i++){
    cin >> a[i];
      mp[a[i]]++;
      if(mp[a[i]] == 1){
        v.pb(a[i]);
    }
  }
  int cnt = 0;
  vector<int> ans;
  for(int i =0 ; i <v.sz;i++){
    if(mp[v[i]] >= n){
      cnt++;
      ans.pb(v[i]);
    }
  }
  cout << cnt << '\n';
  for(int i =0; i <ans.sz;i++){
    cout << ans[i] << ' ';
  }
}	

main()
{
	damkk
    //file()
    int tt = 1;
    //cin >> tt;
    while(tt--){
    	solve();
	}
}


