#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()

using namespace std;

const long long mod = 1000000007, mod3 = 998244353, inf = (ll)1e15;

struct T{
    ll x, y;
};

ll n;

ll k, a[1000005], b[1000005];

map <ll, ll> used;

void query(){
    cin >> n >> k;

    set <ll> s;

    vector <ll> ans;

    for (ll i = 1; i <= k; i++){
        cin >> a[i];

        used[a[i]]++;

        s.insert(a[i]);
    }

    for (auto i : s){
        if (used[i] >= n) ans.pb(i);
    }

    cout << ans.size() << '\n';

    for (auto i : ans) cout << i << ' ';
}
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    ll TT = 1;

    //cin >> TT;

    while(TT--){
        query();
    }

    return 0;
}

/**

*/
