#include <bits/stdc++.h>

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define fi first
#define se second
#define pb push_back
#define fr(i, l, r) for (int i = (l); i <= (r); i++)

using namespace std;
typedef long long ll;

//char c[20][20];
//int cnt[5];

void solve() {
    ll n,m;
    cin>>n>>m;
    map<ll,ll> mp;
    for(int i=0;i<m;i+=1){
        ll x;
        cin>>x;
        mp[x]++;
    }
    vector<ll> v;
    for(auto x : mp){
        if(x.se>=n)v.pb(x.fi);
    }
    cout<<v.size()<<endl;
    for(auto x : v)cout<<x<<" ";
    cout<<endl;
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}
