

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

int main(){
    map <long long, int> kol;
    int n, m ;
    cin >> n >> m; 
    int a[m+1], b[m + 1];
    int kolint = 0;
    
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
        kol[a[i]]++;
        if (kol[a[i]] == n) {
            kolint++;
            b[kolint] = a[i];
        }
    }
    cout << kolint << endl;
    for (int i = 1; i <= kolint; i++) {
        cout << b[i] << ' ';
    }
}
    
    
    