#include <iostream>
#include <vector>
#include <map>
#define endl '\n'
#define int long long
using namespace std;
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    vector<int> a( m);
    for (int i = 0; i < m; i++) cin >> a[i];
    map<int, int> cnt;
    for (auto x : a) cnt[x]++;
    vector<int> e;
    for (auto [u, v]: cnt) {
        if (v >= n) e.push_back(u);
    }
    cout << e.size() << endl;
    for (auto x : e) cout << x << ' ';
    return 0;
}
