// #ifdef ONLINE_JUDGE
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #endif

#include <bits/stdc++.h>
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define precision       \
    cout.precision(11); \
    cerr.precision(11);
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb(x) push_back(x)
#define watch(x) cout << #x << " <-- " << x << '\n';
using namespace std;
class MyExcetion : exception {};

const int N = 1e6 + 5;
const int inf = 1e9 + 3;
const ll mod = 1e9 + 7;

/*
*/

int a[N];
int cnt[N];
set<int> oc;

void solve()
{
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
        oc.insert(a[i]);
    }

    vector<int> ans;

    for (int i : oc)
    {
        if (cnt[i] >= n)
            ans.pb(i);
    }

    cout << sz(ans) << '\n';

    for (int i : ans)
        cout << i << ' ';
}

int main()
{
    std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
    speed;
    precision;
    int T = 1;
    // cin >> T;
    srand(time(0));
    for (int i = 0; i < T; i++)
        solve();
// #ifndef ONLINE_JUDGE
//     std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
//     std::cout << "\nTime difference = " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << "[ms]" << std::endl;
// #endif
}
