//#pragma GCC optimize("0fast")
//#pragma GCC optimize("popcnt, bm2")

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    long long n, m, x; cin >> n >> m;
    map<long long, long long> mp;
    for (long long i = 0; i < m; ++i) {
        cin >> x;
        if (mp.find(x) == mp.end()) {
            mp[x] = 1;
        } else {
            mp[x]++;
        }
    }
    vector<long long> ans;
    for (auto elem : mp) {
        if (elem.second >= n) {
            ans.push_back(elem.first);
        }
    }
    cout << ans.size() << '\n';
    for (auto elem : ans) cout << elem << ' ';
    return 0;
}
