#include<bits/stdc++.h>
#define int int64_t
using namespace std;

void solve(){
    int n,m;
    cin >> n >> m;
    unordered_map<int,int>mp;
    vector<int>a(m);
    for(auto &to : a){
        cin >> to;
        mp[to] ++ ;
    }
    vector<int>ans;
    for(auto [x,y] : mp){
        if(y >= n){
            ans.push_back(x);
        }
    }
    cout << ans.size() << '\n';
    for(auto to : ans){
        cout << to << ' ';
    }
}

int32_t main(){
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int Q = 1;
//    cin >> Q;
    while(Q -- )solve();
    return 0;
}
