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

#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int, int>
#define pll pair<ll, ll>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()

using namespace std;

const int N = (int)3e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 1;
int main() {
    int n, m;
    cin >> n >> m;

    map<int, int> v;
    vector<int> V;

    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;

        if (v.find(x) == v.end()) {
            v[x] = 1;
        } else {
            v[x]++;
        }

        if (v[x] == n) {
            V.pb(x);
        }
    }

    cout << V.size() << endl;
    for (int x : V) {
        cout << x << " ";
    }
}
