#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

#define all(a) a.begin() , a.end()
#define optimus_prime  cin.tie(0); cout.tie(0)
#define endl "\n"
#define vll vector<long long>
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define pb(a) push_back(a)
#define sz size()
#define ll long long
#define F first
#define S second

using namespace std;

const ll N = 101;
const ll inf = 1e9 + 9;
const ll mod = 1e9 + 7;


ll a[N][N];
ll countA = 0;
map<ll, ll> mp;

void solve()
{
    mp.clear();
    ll n, m;
    cin >> n >> m;
    vector<ll> dp(m);
    vector<ll> res;
    int a = 0;
    for(ll i = 0; i < m; i++){
        cin >> dp[i];
        mp[dp[i]]++;
    }
    /*
    cout << endl;
    for(auto i : mp){
        cout << i.F << " " << i.S << endl;
    }
    */
    for(auto i : mp){
        if(i.S >= n){
            a++;
            res.pb(i.F);
        }
    }

    cout << a << endl;
    for(int i = 0; i < res.sz; i++){
        cout << res[i] << " ";
    }


}

signed main()
{
    optimus_prime;

    int t;
    t = 1;
    //cin >> t;

    while(t--)
         solve();





    return 0;
}
