#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
    int n, m;
    cin >> n >> m;
    map<int, int> a;
    vector<int> b;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        a[x]++;
        if (a[x] == n) {
            b.push_back(x);
        }
    }
    cout << b.size() << "\n";
    for (int i : b) {
        cout << i << " ";
    }
    return 0;
}










