#include <bits/stdc++.h>
#include <set>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define WHAT ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define cin(x, N) for(int i = 1; i <= N; i ++) cin >> x[i]
#define reset(x, N) for(int i = 1; i <= N; i ++) x[i] = 0;
#define sortvec(x) sort(x.begin(), x.end())
#define open_file(intput, output) freopen("input","r",stdin);freopen("output","w",stdout)
void solve(){}
int main(){
    WHAT
    int N, M, a;
    vector <int> ans;
    cin >> N >> M;
    map <int, int> mp;
    for(int i = 1; i <= M; i ++){
        cin >> a;
        if(mp.count(a) == 0) mp[a] = 1;
        else mp[a] ++;
    }
    map <int, int> :: iterator it = mp.begin();
    while(it != mp.end()){
        if(it->second >= N) ans.pb(it->first);
        it ++;
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i ++) cout << ans[i] << " ";
}