#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define mii map<int,int>
#define ll long long
#define st string
#define S second
#define F first
#define lf else if

using namespace std;
ll n,m;
//const int inf = 2e9;
map <ll,ll> mp;
vector <ll> v(300100);
vector <ll> ans;
void why()
{
    cin>>n>>m;
    for(ll i=1;i<=m;i++)
    {
        cin>>v[i];
        mp[v[i]]+=1;
    }
    for(ll i=1;i<=m;i++)
    {
        if(mp[v[i]]>=n)
        {
            ans.pb(v[i]);
            mp[v[i]]=0;
        }
    }
    cout<<ans.size()<<"\n";
    for(auto to: ans)
    {
        cout<<to<<" ";
    }
}

//build(1, 1, n);
//get(1, 1, n, l, r);
//upd(1, 1, n, p, x);
signed main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    //srand( time(0));
 //rand()
 //freopen("sum.in", "r", stdin);
 //freopen("sum.out", "w", stdout);
 why();
    return 0;
}


//1 2 3 4
