#include <bits/stdc++.h>

#define mp make_pair
#define ull unsigned long long
#define ll long long
#define forn(i, n) for(int i = 0; i < n; i++)
using namespace std;


void start() {
    int n, m;
    cin >> n >> m;
    ll a[m];
    forn(i, m) cin >> a[i];
    sort(a, a + m);

    vector<int> ans;
    int cnt = 1;
    for(int i = 1; i < m; i++) {
        if (a[i] == a[i - 1]) {
            cnt++;
        }
        else {
            if (cnt >= n) {
                ans.push_back(a[i - 1]);
            }
            cnt = 1;
        }
    }
    if (cnt >= n) {
        ans.push_back(a[m - 1]);
    }

    cout << ans.size() << "\n";
    forn(i, ans.size()) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--)
        start();
}