#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int>u(m);
    vector<int>p;
    for (int i = 0; i < m; i++) {
        cin >> u[i];
    }
    sort(u.begin(), u.end());
    int sum = 1;
    if (n == 1) {
        p.push_back(u[0]);
    }
    for (int i = 1; i < m; i++) {
        if (u[i] == u[i - 1]) {
            sum++;
        }
        else {
            sum = 1;
        }
        if (sum == n) {
            p.push_back(u[i]);
        }
    }
    cout << p.size() << '\n';
    for (int i = 0; i < p.size(); i++) {
        cout << p[i] << " ";
    }
}