#include<bits/stdc++.h>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    sort (a, a + m);
    map <int, int> mp;
    for (int i = 0; i < m; i++) {
        mp[a[i]]++;
    }
    map <int, int> :: iterator it;
    int i = 0;
    for (it=mp.begin(); it != mp.end(); it++) {
        int p = it->second;
        if (p >= n) {
            i++;
        }

    }
    cout << i << endl;
    for (it=mp.begin(); it != mp.end(); it++) {
        int p = it->second;
        if (p >= n) {
            cout << it->first << " ";
        }

    }
}
