#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n, k, x, res = 0;
	unordered_map<int, int> m;
	vector<int> v;
	cin >> n >> k;
	
	for (int i = 0; i < n; ++i) {
		cin >> x;
		++m[x];
	}
	
	for (auto it = m.begin(); it != m.end(); ++it) {
		if (it->second >= 2) {
			++res;
			v.emplace_back(it->first);
		}
	}
	
	cout << res << "\n";
	
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i] << " ";
	}
}