#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define F first
#define S second
using namespace std;
const int SIZE = 3e5 + 5;
const ll mod = 1e9 + 7;

int n, m;
int a[SIZE];
multiset <int> mst;
set <int> bull;
vector <int> v;

void solve() {
    mst.clear();
    bull.clear();
    v.clear();

	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
        cin >> a[i];
        mst.insert(a[i]);
        bull.insert(a[i]);
	}

    for (auto x : bull) {
        if (mst.count(x) >= n) {
            v.push_back(int(x));
        }
    }

	cout << v.size() << "\n";
	for (auto x : v) {
        cout << x << " ";
	}
	return;
}

int main() {
    speed;

	int TIME;
	TIME = 1;
	//cin >> TIME;
	while (TIME-- > 0) {
		solve();
		cout << "\n";
	}
	return 0;
}
