#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <random>
#include <numeric>
#include <map>
#include <set>
#include <string>

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

#define deb(x) cerr << #x << ":\t" << x << '\n';
#define len(x) (ll) x.size()

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

void solve() {
    ll n, m; cin >> n >> m;
    map <ll, ll> cnt;
    vector <ll> ans;
    for (ll i = 0; i < m; i++) {
        ll x; cin >> x;
        cnt[x]++;
    }
    for (auto i : cnt) {
        if (i.second >= n) {
            ans.emplace_back(i.first);
        }
    }
    cout << ans.size() << '\n';
    for (auto i : ans)
        cout << i << ' ';
}

int main() {
    int T = 1;
    //    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
