#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(){
    ll n, m, value;
    cin >> n >> m;
    vector<ll> was, res;

    for (int i = 0; i < m; i++)
    {
        cin >> value;
        was.push_back(value);
    }
    for (ll i = 0; i < was.size(); i++)
    {
        if (count(was.begin(), was.end(), was[i]) >= n) {
            value = was[i];
            res.push_back(value);
            for (int j = 0; j < n; j++) {
                was.erase(find(was.begin(), was.end(), value));
            }
        }
    }
    

    cout << res.size() << endl; 
    for (auto &&i : res)
    {
        cout << i << ' ';
    }
    cout << endl;
}

