#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;
int main() {

    ll n, i, j, k, m;

    cin >> n >> m;

    vector<ll> a(m + 1), b;
    map<ll, ll>mp;

    for(i = 1; i <= m; ++i)
    {
        cin >> a[i];
        ++mp[a[i]];
    }

    for(i = 1; i <= m; ++i)
    {
        if(mp[a[i]] >= n)
        {
            b.push_back(a[i]);
        }
        mp[a[i]] = 0;
    }

    cout << b.size() << '\n';
    for(auto i : b)
        cout << i << ' ';
}
