#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define f first
#define s second  
#define int long long 
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back()
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
int mod = 998244353;
struct abcd{
    int a;
    int b;
};
bool comp(abcd a,abcd b){
    if(a.a==b.a){
        return a.b>b.b;
    }
    return a.a<b.a;
}
const int INF = 1e18;
const int N = 1e6 + 5;
int fact(int n) {
  if(n > 1)
    return ((n%998244353) * (fact(n - 1)%998244353))%998244353;
  else
    return 1;
}
int mind[N];
void precalc() {
    for(int i=0;i<N;i++)
		mind[i] = i;
	
	for (int p = 2; p < N; p++) {
		if (mind[p] == p)
		for (int d = 2 * p; d < N; d += p)
			mind[d] = min(mind[d], p);
	}
}
map<int,int>man;
void getPrimes(int h) {
	vector<int> ps;
	while (h > 1) {
		man[mind[h]]++;
		h /= mind[h];
	}
}
void solve(){
    int q,k,bo=0,n=0,m,a=1,b=0,d=0,c=1,e=0,l=1,r=n,h=10000000000,f=-1,x=0,y,z=31,len=1e10,x1,y1,sum=0;
    cin>>m>>n;
    set<int>s;
    multiset<int>se;
    vector<int>v;
    for(int i=0;i<n;i++){
        cin>>a;
        se.insert(a);
        s.insert(a);
    }
    for(auto k:s){
        d=se.count(k);
        if(m<=d){
            v.push_back(k);
        }
    }
    cout<<v.size()<<"\n";
    for(auto k:v){
        cout<<k<<" ";
    }
}
signed main(){
    fast;
    int q=1;
    //cin>>q;
    while (q--){
        solve();
	}
}
