#include <cstdio>
#include <set>

int main()
{
  int s, t; //number of integers for S and T

  int count = 0; // number of integers of T in S
  
  std::set<int> S; // set S to be checked against

  scanf("%d", &s);
  
  for (int i = 0; i < s; ++i) {
    int input;
    scanf("%d", &input);
    S.insert(input);
  }

  scanf("%d", &t);

  for (int i = 0; i < t; ++i) {
    int input;
    scanf("%d", &input);
    if ( S.find(input) != S.end() ) ++count; // increment count if found in S
  }

  printf("%d\n", count);
}
    
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<algorithm>
#include<functional>
using namespace std;

int n,q;
int a=0;
int c=0;
int s[10000]={};
int t[10000]={};




int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
	cin>>s[i];
	}

	cin>>q;
	for(int j=0;j<q;j++)
	{
	cin>>t[j];
	}

	for(int k=0;k<n;k++)
	{
	for(int l=0;l<q;l++)
	{
	a=s[k]^t[l];
	if(a==0)
	{
	c+=1;
	t[l]=-1;
	}
	}
	
	}
	cout<<c<<endl;
	return 0;
}