#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll a,b;
    cin >> a >> b;
    vector<ll> arr(b);
    for(int i=0; i < b; i++) {
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    ll c=1;
    vector < ll > array;
    ll g=arr[0];
    for(int i=1; i < b; i++) {
        if(arr[i] == g ) {
            c++;
        }
        else {
            if(c >= a)
            array.push_back(g);
            g=arr[i];
            c=1;
        }
    }
    cout << array.size() << "\n";
    for(int i=0; i < array.size(); i++) {
        cout << array[i] << " ";
    }
    return 0;
}
