///Shapo4ka
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vii;
typedef vector<ll> vll;

ll bpow(ll a, int n)
{
    ll ans=1;
    while(n)
    {
        if (n & 1)ans*=a;
        a*=a;
        n/=2;
    }
    return ans;
}
int n,m,ans;
ll c;
map<ll,int>mp;
vll v;
int main()
{
    cin >> n >> m;
    for (int i=0;i<m;i++)
    {
        cin >> c;
        mp[c]++;
    }
    for (auto i:mp)
    {
        if (i.se >= n){ans++;v.pb(i.fi);}
    }
    cout << ans << "\n";
    for (int i=0;i<ans;i++)cout << v[i] << " ";
    cout << "\n";
    return 0;
}
/*
10 9 3
*/
