#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    vector<int> b;
    sort(a, a + m);
    int count = 0, kol = 1;
    for (int i = 0; i < m - 1; i++) {
        if (a[i] == a[i + 1]) {
            kol++;
        }
        else {
            if (kol >= n) {
                count++;
                b.push_back(a[i - 1]);
            }
            kol = 1;
        }
    }
    if (kol >= n) {
        count++;
        b.push_back(a[m - 1]);
    }
    cout << count << "\n";
    for (vector<int>::iterator i = b.begin(); i < b.end(); i++) {
        cout << *i << " ";
    }
}