#include <bits/stdc++.h>
#define ll long long
using namespace std;

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