#include <bits/stdc++.h>
#define ll long long



using namespace std;

void Xatab(){
    ll n, m;cin>>n>>m;
    ll k=0;
    map <ll, ll> mp;
    vector <ll> s;
    vector <ll> b;
    vector <ll> a(m);
    for(int i=0; i<m; ++i){cin>>a[i];mp[a[i]]++;b.push_back(a[i]);}
    for(auto i: mp){
        if(i.second >= n)s.push_back(i.first);
    }
    for(int i=0; i<b.size(); ++i){
        for(int j=i+1; j<b.size(); ++j){
            if(b[i] == b[j])b.erase(b.begin() + j);
        }
    }
    cout<<s.size()<<"\n";
    for(int i=0; i<b.size(); ++i){
        for(int j=0; j<s.size(); ++j){
            if(b[i] == s[j])cout<<s[j]<<" ";
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll T = 1;//cin>>T;
    while(T--)Xatab();
    return 0;
}

