#include <bits/stdc++.h>
#define endl '\n'
#define int ll
#define ve vector
#define pb push_back


using namespace std;
typedef long long ll;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif // LOCAL
    ll n , m;
    cin >> n >> m;
    int a[m];
    map < int , int> cnt;
    for(int i = 0;i < m;++ i)
    {
        cin >> a[i];
        cnt[a[i]] ++;
    }
    ve <int> ans;
    for(int i = 0;i < m;++ i)
    {
        if(cnt[a[i]] >= n)
        {
            ans.pb(a[i]);
            cnt[a[i]] = -1;
        }
    }
    cout << ans.size() << endl;
    for(auto to : ans)
    {
        cout << to << ' ';
    }

}
