#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n, m;
    cin>>n>>m;
    vector<int> f;
    map<int, int> v;
    for(int i = 0; i < m; i++){
        int x;
        cin>>x;
        if(!v.count(x)) v[x] = 0;
        v[x]++;
        if(v[x] == n) f.push_back(x);
    }
    cout << f.size() << "\n";
    for(auto u: f){
        cout << u << " ";
    }
    return 0;
}
