#include <iostream>
#include <vector>
using namespace std;

int main() {
        int n, m, count=1, trackVar=0;
        bool b=true;
        cin >> n;
        cin >> m;
        vector<int> q(m);
        vector<int> output;
        for (int i=0; i<m; i++){
                cin >> q[i];
        }
        for (int i=0; i<m; i++){
                trackVar=q[i];
                for (int j=i+1; j<m; j++){
                        if (q[j]==trackVar){
                                count++;
                        }
                }
                if (count>=n){
                        for (int k=0; k<size(output); k++){
                                if (output[k]==trackVar){
                                        b=false;
                                }
                        }
                        if (b){
                                output.push_back(trackVar);
                        }
                }
                b=true;
                count=1;
                
        }
        cout << size(output) << "\n";
        for (int i=0; i<size(output); i++){
                cout << output[i] << " ";
        }
        
}

