#include <stdio.h>
#define SMAX 10000
#define TMAX 500


int main( )
{
  int i=0,j=0,n,q,count=0;
  int S[SMAX],T[TMAX];
  
  scanf("%d",&n);
 
  while(i < n){
    scanf("%d",&S[i]);
    i++;
  }
  
  scanf("%d",&q);

  
  while(j < q ){
  scanf("%d",&T[j]);
  j++;
  }

 int left = 0, right = n, mid;
 j = 0;
 while( left < right){
    mid = (left + right) /2;
    if(S[mid] == T[j]){
      count++;
      break;
    }
    else if (T[mid] < S[mid]){
      left = mid + 1;
      }
    else {
      right = mid - 1;
    }
    j++;
 }
  
 printf("%d\n",count);

 return 0;
}
 