#include <iostream>
#include <vector>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int c[b];
    for(int i = 0; i < b; i++){
        cin >> c[i];
    }
    vector<int> unique;
    for(int i = 0; i < b; i++){
        int g = c[i];
        int found = 0;
        for(int j = 0; j < unique.size(); j++){
            if(unique[j] == g){
                found = 1;
            }
        }
        if(found == 0){
            unique.push_back(c[i]);
        }
    }
    int t = 0;
    vector<int> found;
    for(int i = 0; i < unique.size(); i++){
        for(int j = 0; j < b; j++){
            if(c[j] == unique[i]){
                t++;
            }
        }   
        if(t >= a){
            found.push_back(unique[i]);
        }
        t = 0;
    }
    cout << found.size() << endl;
    for(int i = 0; i < found.size(); i++){
        cout << found[i] << " ";
    }
}
/*2 10
1 3 6 5 3 2 4 5 3 2
*/