

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

void solve()
{
    int n,m;
    cin>>n>>m;
    if(n==1){
        cout<<m*((m+2)/2);
    }
    else if(m==1){
        cout<<n*((n+2)/2);
    }
    else{
        int o1=((n+1)*n/2-1)*m+2*n*m;
        swap(n,m);
        int o2=((n+1)*n/2-1)*m+2*n*m;
        cout<<max(o1,o2);
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    int a;
    map<int, int> mp;
    for (int i = 0; i < m; ++i){
        cin >> a;
        mp[a]++;
    }

    vector<int> ans;
    for (auto i : mp){
        if (i.second >= n){
            ans.push_back(i.first);
        }
    }

    cout << ans.size() << endl;
    for (int i : ans){
        cout << i << " ";
    }
}
