#include<bits/stdc++.h>
#define ll long long
using namespace std;
map < ll , ll > mp;
map < ll , bool > mp1;
void solve()
{
      int n , k;
    cin >> n >> k;
    vector < ll > vc;
    int a;
    for(int i = 0; i < k; ++i)
    {
        cin >> a;
        mp[a]++;
        if(mp[a]>=n and mp1[a]==false)
        {
            vc.push_back(a);
            mp1[a]=true;
        }
    }
    cout << vc.size() << endl;
    for(auto i : vc)
    {
        cout << i << " ";
    }
}
int main ()
{
    ll T=1;
    //cin >> T;
    while(T --)
    {
      solve ();
    }
}
