#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define vec vector
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

using namespace std;

const int MAX = 2e5 + 7;
bool us[10][10];

void fil(int x,int y){
    us[x][y]=true;
    us[max(0,x-1)][max(0,y-1)]=true;
    us[max(0,x-1)][y]=true;
    us[max(0,x-1)][min(9,y+1)]=true;
    us[x][max(0,y-1)]=true;
    us[x][y]=true;
    us[x][min(9,y+1)]=true;
    us[min(9,x+1)][max(0,y-1)]=true;
    us[min(9,x+1)][y]=true;
    us[min(9,x+1)][min(9,y+1)]=true;
}

void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> res;
    map<int, int> cnt;
    for (int i = 1; i <= k; i++) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    for (auto [x, y] : cnt) if (y >= n) {
        res.push_back(x);
    }
    cout << sz(res) << endl;
    for (auto i : res) cout << i << ' ';
    return;
    vector<string> s(10);
    int i,j,k1=0,k2=0,k3=0,k4=0;
    for (i=0;i<10;i++)cin>>s[i];
    for (i=0;i<10;i++){
        for (j=0;j<10;j++){
            if (s[i][j]!='#')continue;
            int k=0;

        }
    }
}

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