#include <bits/stdc++.h>
using namespace std;
int main ()
{
	freopen ("DEMPT.inp", "r", stdin);
	freopen ("DEMPT.out", "w", stdout);
	long a[100001], z[100000];
	long b,c,d=1,e=1,f=0;
	cin >> b;
	for (int i=1; i<=b; i++)
	cin>> a[i];
	a[b+1]=-1;
	cin>> c;
	for (int i=1 ; i<=c; i++)
	cin>> z[i];
	sort (a+1, a+b+1);
	while (d<=c)
	{
		if (z[d]==a[e]) {f++; d++;e=1;}
		if (d==c) break;
		if (z[d]>a[e]) e++;
		if (z[d]<a[e]) {d++; e=1;}
	}

	cout << f;
}
