#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937_64 rnd(time(0));
#define push_back pb
#define make_pair mp
#define F first
#define S second
#define all(x) x.begin(), x.end()

const ll N = 2e5 + 5;
const ll INF = 1e15;

void solve() {
    int n, m; cin >> n >> m;
    vector<int> c(m);
    map<int, int> cnt;
    set<int> possible;
    for (int i = 0; i < m; i++) {
        cin >> c[i];
        cnt[c[i]]++;
        if (cnt[c[i]] >= n) possible.insert(c[i]);
    }
    cout << possible.size() << endl;
    for (auto x : possible) cout << x << " ";
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    solve();

    return 0;
}