#include <bits/stdc++.h>

#define endl '\n'

#define debug(x) std::cerr << __FUNCTION__ << ':'<< __LINE__ << ' ' << #x << " = " << x << endl

using ll = long long;
using ull = unsigned long long;

using namespace std;

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

    ll n, m,;
    cin >> n >> m;
    vector<ll> was(m);
    unordered_set<ll> res;

    for (int i = 0; i < m; i++)
    {
        cin >> was[i];

        if (count(was.begin(), was.end(), was[i]) >= n) {
            res.insert(was[i]);
            for (int j = 0; j < n; j++) {
                was[i] = 0;
            }
        }
    }
    
    cout << res.size() << endl; 
    for (auto &&i : res)
    {
        cout << i << ' ';
    }
    cout << endl;
}

