#include <bits/stdc++.h>

using namespace std;

int main(){
    int k, n;
    cin >> k >> n;
    unordered_map < int, int> mp;
    vector < int > el;
    for(int i = 1; i <= n; i ++) {
        int x;
        cin >> x;
        mp[x] ++;
    }
    for(auto it : mp) {
        if(it.second >= k) {
            el.push_back(it.first);
        }
    }
    cout << el.size() << '\n';
    for(auto it : el) {
        cout << it << ' ';
    }
}
