#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	ll n, m;
	cin >> n >> m;

	map<ll, ll> arr;
	vector<ll> ans;
	for (ll i = 0; i < m; ++i) {
		ll x;
		cin >> x;
		arr[x]++;

		if (arr[x] / n >= 1) {
			ans.push_back(x);
			arr[x] = -1'000'000'000'000ll;
		}
	}

	cout << ans.size() << '\n';
	for (auto x : ans) {
		cout << x << ' ';
	}
}