#include <bits/stdc++.h>
#define int long long
#define ll long long
#define str string
#define ld long double
#define run_vasya_run ios_base::sync_with_stdio(0) , cin.tie(0) ,cout.tie(0)
#define uint unsigned long long
#define fi first
#define se second
#define pb push_back
#define open freopen ("log.in", "r", stdin);
#define close freopen("log.out", "w", stdout);
using namespace std;
const int MOD = 10000000007;
ll _ , n , m , a[500000];
map<ll,ll>us;
vector<ll>ans;
main()
{
    //run_vasya_run;
    _ = 1;
    //open;
    //close;
    //cin >> _;
    while(_ --)
    {
        cin >> n >> m;
        for(int i = 1;i <= m;i ++)
        {
            cin >> a[i];
            us[a[i]] ++;
        }
        for(int i = 1;i <= m;i ++)
        {
            if(us[a[i]] >= n)
            {
                ans.push_back(a[i]);
            }
            us[a[i]] = 0;
        }
        cout << ans.size() << endl;
        for(auto to : ans)
        {
            cout << to << ' ';
        }
    }
}
