#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> arr(m);
    for (int i = 0; i < m; ++i) {
        cin >> arr[i];
    }

    sort(arr.begin(), arr.end());
    vector<int> ans;
    int prev = arr[0], cnt = 0;
    for (int i = 0; i < m; ++i) {
        if (arr[i] == prev) {
            cnt++;
        }
        else {
            if (cnt >= n) {
                ans.push_back(prev);
            }
            cnt = 1;
            prev = arr[i];
        }
    }
    if (cnt >= n) {
        ans.push_back(arr[m - 1]);
    }
    
    cout << ans.size() << "\n";
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << " ";
    }

    return 0;
}

