#include <bits/stdc++.h>
using namespace std;
void rev(vector<int>& v)
{
    for( auto base = v.begin(); base != v.end(); ++base )
    {
        for( auto it = base + 1; it != v.end(); )
        {
            if( *base == *it )
            {
                it = v.erase(it);
            }
            else
            {
                ++it;
            }
        }
    }
}
int main(){
    int m, n, c = 0;
    cin >> m >> n;
    vector<int> a(n), v;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++){
        if (count(a.begin(), a.end(), a[i]) >= m)
            v.push_back(a[i]);
        }
    rev(v);
    cout << v.size() << "\n";
    for (int i = 0; i < v.size(); i++)
        cout << v[i] << " ";
}
