#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;
    long long mas[m];
    vector<long long> raz;
    for (long long i = 0; i < m; ++i) {
        cin >> mas[i];
    }
    sort(mas, mas + m);
    long long i = 0;
    long long sum = 0;
    while (i < m) {
        long long a = mas[i];
        long long kol = 1;
        while (i < m - 1 && mas[i] == mas[i + 1]) {
            ++kol;
            ++i;
        }
        if (kol >= n) {
            raz.push_back(a);
            ++sum;
        }
        ++i;
    }
    cout << sum << endl;
    for (long long j = 0; j < raz.size(); ++j) {
        if (j == raz.size() - 1) { cout << raz[j]; }
        else { cout << raz[j] << " "; }
    }
    return 0;
}