#include <bits/stdc++.h>

using namespace std;
#define ll long long
int main()
{
    ll n, m;
    cin >> n >> m;

    vector < pair < ll , ll > > v;
    map < ll , ll > mp;
    for (int i = 0; i < m; i++) {
        ll x;
        cin >> x;
        mp[x]++;
    }

    for (auto x : mp)
        if (x.second >= n)
    v.push_back({x.second, x.first});

    sort(v.rbegin(), v.rend());
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++)
        //if (v[i].first > n - 1)
        cout << v[i].second << " ";
}
