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

int main() {
    int K, N;
    cin >> K >> N;
    vector<int>b(0);
    vector<int> numbers(N);
    bool wtf[N]={false};
    unordered_map<int, int> frequencyMap;
    for (int i = 0; i < N; i++) {
        cin >> numbers[i];
        frequencyMap[numbers[i]]++;
        if(frequencyMap[numbers[i]] >= K){
            if(wtf[numbers[i]]==false){
                b.push_back(numbers[i]);
                wtf[numbers[i]]=true;
            }
        }
    }
    cout<<b.size()<<'\n';
    for(int i=0;i<b.size();i++){
        cout<<b[i]<<' ';
    }

    

    

    cout ;

    return 0;
}