#include<stdio.h>
 
#define N 10000
#define Q 500
 
int main()
{
  int i, j, count=0;
  int S[N], T[Q];
   
  scanf("%d", &S[0]);

  while(1)
    {
      int i=0, a=0;
      for(i=1; i<S[0]+1; i++)
	{
	  scanf("%d", &S[i]);
	}
      for(i=1; i<S[0]+1; i++)
	{
	  if(S[i] <= 10*10*10*10*10*10*10*10*10 && S[i] >= 0)
	    {
	      a = a + 1;
	    }
	}
      if( a    == S[0])break;
    }
	  

  scanf("%d", &T[0]);
 
  while(1)
    {
      int i=0, b=0;
      for(i=1; i<T[0]+1; i++)
	{
	  scanf("%d", &T[i]);
	}
      for(i=1; i<T[0]+1; i++)
	{
	  if(T[i] <= 10*10*10*10*10*10*10*10*10 && T[i] >= 0)
	    {
	      b = b + 1;
	    }
	}
      if( b    == T[0])break;
    }
	  
   
  for(i=1; i<S[0]+1; i++)
    {
      for(j=1; j<T[0]+1; j++)
    {
      if(S[i] == T[j])
        {
          count = count + 1;
        }
    }

    }
    printf("%d\n", count);

return 0;
  }