#include <bits/stdc++.h>
 
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define si set<int>
#define sz(s) (int)s.size()
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define all(v) v.begin(), v.end()
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
#define r0 return 0

using namespace std;

const int mod = 1e9 + 7, N = 1e5 + 5, INF = 1e9;
const long long INF2 = 1e18;

void solve(){
    int n, m;
    cin >> n >> m;
    int a[m];
    for(int i = 0; i < m; i++){
        cin >> a[i];
    }
    sort(a, a + m);
    int x = a[0], k = 1;
    vi v;
    for(int i = 1; i < m; i++){
        if(x == a[i]){
            k++;
        } else{
            if(k == n or k == n + 1){
                v.pb(x);
            }
            x = a[i];
            k = 1;
        }
    }
    cout << sz(v) << endl;
    for(int i = 0; i < sz(v); i++){
        cout << v[i] << " ";
    }
}

void cf() {int tt;cin >> tt;while(tt--){solve();}}

int main(){
	boost
	//cf();
	
	solve();

	r0;
}