#include <bits/stdc++.h>
using namespace std;
void remove(std::vector<int> &v) {
    std::unordered_set<int> s;
    auto end = std::remove_copy_if(v.begin(), v.end(), v.begin(),
                        [&s](int const &i) {
                            return !s.insert(i).second;
                        });
    v.erase(end, v.end());
}
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]);
        }
    remove(v);
    cout << v.size() << "\n";
    for (int i = 0; i < v.size(); i++)
        cout << v[i] << " ";
}
