#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define f first
#define s second
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) begin(x), end(x)

using namespace std;

const int N = 2e5 + 1, inf = LLONG_MAX / 2ll ;

void solve() {
    int n,m;
    cin >> n >> m;
    int a[m + 1];
    map <int,int> g;
    for(int i = 1;i <= m;i++) {
        cin >> a[i];
        g[a[i]]++;
    }
    vector <int> ans;
    for(auto x:g) {
        if(x.s >= n) {
            ans.pb(x.f);
        }
    }
    cout << sz(ans) << endl;
    for(auto x:ans) cout << x << " ";
    cout << endl;
    return ;
}

signed main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);cout.tie(0);
    int T = 1 ;
    while (T--) {
        solve ( ) ;
    }
    return 0 ;
}