#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ld long double
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
using namespace std;
void solve(){
ll n,m;
cin >> n >> m;
vector<ll> a(m),b;
for(ll i=0; i<m; i++)
    cin >> a[i];
sort(all(a));
//for(ll i=0; i<m; i++)
//    cout << a[i] << ' ';
ll k=0;
for(ll i=0; i<m; i++){
    if(a[i]==a[i+1])k++;
    else {
        k++;
        if(k>=n) b.pb(a[i]);
            k=0;
    }
}
cout << sz(b) << '\n';
for(ll i=0; i<sz(b); i++)
    cout << b[i] << ' ';
}

int main()
{
    solve();
    return 0;
}
