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

