#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long 
#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const int MAXN=2*1e5+7;
int a[MAXN];
bool used[MAXN];

void solve(ll test_case)
{
    int n,m;
    cin>>m>>n;
    map<int,int>mp;
    vector<int>ans;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(used[a[i]]==0&&mp[a[i]]>=m)
        {
            used[a[i]]=1;
            ans.push_back(a[i]);
        }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<' ';
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t, t1 = 0;
    t=1;
    while (t1 < t)
    {
        solve(t1 + 1);
        t1++;
    }
}