#include <iostream>
#include <fstream>
#include <algorithm>
int d[1000000];
using namespace std;
int main()
{
	ifstream fi("dc.inp");
	ofstream fo("dc.out");
	int m,n,b[10000],a[10000],c[10000],dem = 0;
	fi >> n >> m;
    for (int i = 0; i < n; i++) {fi >> a[i]; d[a[i]] = 1;}
    for (int i = 0; i < m; i++)
    {
        fi >> b[i];
        if (d[b[i]] == 1)
        {
            c[dem] = b[i];
            dem++;
        }
    }
    fo << dem << endl;
    sort(c,c+dem);
    for (int i = 0; i < dem; i++) fo << c[i] << " ";
	return 0;
}
