#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

#define int long long
#define double long double

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, ch = 0;
    cin >> n >> m;
    vector <int> a(m), ans;
    for(int i = 0; i < m; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < m; i++) {
        ch = 0;
        if(i < m - 1 && a[i] == a[i + 1]) {
            ch++;
            while(i < m - 1 && a[i] == a[i + 1]) {
                ch++;
                i++;
            }
            if(ch >= n) {
                ans.push_back(a[i]);
            }
        }
        if(n == 1) {
            ans.push_back(a[i]);
        }
    }
    cout << ans.size() << endl;
    cout << ans[0];
    for(int i = 1; i < ans.size(); i++)
        cout << " " <<ans[i];
    return 0;
}
