#ifdef Local
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;


template<typename T>
istream &operator>>(istream &in, vector<T> &a) {
    for (auto &i: a)in >> i;
    return in;
}

template<typename T>
ostream &operator<<(ostream &out, vector<T> &a) {
    for (auto &i: a)out << i << ' ';
    return out;
}
ll rec(ll w, ll h){
    if(w==h&&w==1){
        return 1;
    }
    if(w%2==0){
        return 2*rec(w/2, h)+w*h;
    }
    if(h%2==0){
        return 2*rec(w, h/2)+w*h;
    }
    if(w<h){
        swap(h, w);
    }
    return rec(w/2, h)+rec(w/2+1, h)+w*h;
}
int sz =1000000000;
void solve2(){
//    int n, m, r; cin >> n >> m >> r;
//    vector<int> d(sz, 0);
//    map<int, int> m;
//    for (int i = 0; i < n; ++i){
//        int dn, w; cin >> dn >> w;
//        m[dn-1] = w;
//    }for (int i = 0; i < sz; ++i){
//        if (m[i-1] != 0 and i > 0) d[i] = d[i-1]
//        if (m[i] == 0 and i > 0) d[i] = d[i-1];
//        else{
//            if (i>0) d[i] = d[i-1]
//        }
//    }
}
void solve() {
    ll n, m;
    cin>>n>>m;
    vector<ll> v(m);
    cin>>v;
    vector<ll> ans;
    map<ll, ll> mp;
    for(int i= 0; i<m; i++){
        mp[v[i]]++;
    }
    for(auto [x, y]:mp){
        //cout<<x<<" "<<y<<"\n";
        if(y>=n){
            ans.push_back(x);
        }
    }
    cout<<ans.size()<<"\n";
    cout<<ans<<"\n";
}

signed main() {
#ifdef Local
    freopen("in.in","r",stdin);
    freopen("out.out","w",stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#endif
    int t = 1;
    if (t == -1)cin >> t;
    for (int i = 0; i < t; i++)solve();
}

