#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include <map>
using namespace std;
const long long maxn = 1000001;
int main() {
    int n,m; cin >> n >> m;
    map<int, int> maps;
    for (int i=0; i<m; i++) {
        int gg; cin >> gg;
        maps[gg]++;
    }
    vector <int> answer;
    for (auto elem: maps) {
        if (elem.second >= n) {
            answer.push_back(elem.first);
        }
    }
    cout << answer.size() << "\n";
    for (auto elem:answer) {
        cout << elem << " ";
    }
    return 0;
}