#include <bits/stdc++.h>
#define ll long long
using namespace std;
void remove(vector<ll> &v) {
    vector<ll>::iterator itr = v.begin();
    unordered_set<ll> s;
    for (auto curr = v.begin(); curr != v.end(); ++curr)
    {
        if (s.insert(*curr).second) {
            *itr++ = *curr;
        }
    }

    v.erase(itr, v.end());
}
int main(){
    ll m, n, c = 0;
    cin >> m >> n;
    vector<ll> a(n), v;
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    for (ll i = 0; i < n; i++){
        if (count(a.begin(), a.end(), a[i]) >= m)
            v.push_back(a[i]);
        }
    remove(v);
    cout << v.size() << "\n";
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
}
