#include <fstream>
using namespace std;
int main ()
{
	ifstream f("dempt.inp");
	ofstream g("dempt.out");
	long long m,n,a[999999],b[999999],d[999999],dem=0;
    int i,j;
    f>>n;
    for (i=1;i<=n;i++)
    { f>>a[i];
	  d[a[i]]=1;}
    f>>m;
    for (j=1;j<=m;j++)
    { f>>b[j];
	   }
    for (j=1;j<=m;j++)
    {
    	if (b[j]==1)
    	{ dem++; }
    }
    g<<dem;
    f.close();
    g.close();
}
    
 

