#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
using namespace std;

int count(const vector<long long>& vec, long long n) {
    int count = 0;
    
    for (long long num : vec) {
        if (num == n) {
            count++;
        }
    }
    
    return count;
}
int main() {
    long long n, m;
    cin >> n >> m;
    vector<long long> costs(m);
    set <long long> p;
    for (long long i = 0; i < m; i++) {
        cin >> costs[i];
        p.insert(costs[i]);
    }
    vector <long long> results;
    for (auto now:p) {
        int x=count(costs,now);
       if (n<=x) { results.push_back(now);}
    }

 

    cout<<results.size()<<endl;
    for (auto now : results) {
        cout <<now<< " ";
    }

    return 0;
}