#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, m, x = 0;
    cin >> n >> m;
    vector<long long> zxc;
    vector<long long> arr;
    for (long long i = 0; i < m; i++)
    {
        long long num;
        cin >> num;
        zxc.push_back(num);
    }
    sort(zxc.begin(), zxc.end());
    for (long long i = 0; i < zxc.size()-1; i++) {
        if (zxc[i] == zxc[i + 1]) {
            zxc.erase(zxc.begin() + i);
            i--;
            x++;
        }
        else if (x >= n-1) { arr.push_back(zxc[i]); x = 0; }
        else x = 0;
    }
    cout << arr.size() << endl;
    for (long long i : arr) {
        cout << i << " ";
    } cout << endl;
    return 0;
}