#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	ifstream input("daychung.inp");
	ofstream output("daychung.out");

	long long n, m;
	input >> n >> m;
	vector <long long> a(n);
	vector <long long> b(m);
	for (int i = 0; i < n; i++)
	{
		input >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		input >> b[i];
	}
	vector <long long> result;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(result));
	output << result.size() << '\n';
	for (int i = 0; i < result.size(); i++)
	{
		output << result[i] << ' ';
	}
	input.close();
	output.close();
	return 0;
}