#include<stdio.h>

#define MAX_S 100000
#define MAX_T 50000

int binarySearch(){
  int n,q,count,i,j,mid,r,l,a,b,c;
  int s[MAX_S],t[MAX_T];

  count = 0;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++)
    scanf("%d",&t[i]);

  a = 0;
  b = n / 2;
  c = n - 1;
  l = s[a];
  mid = s[b];
  r = s[c];
  for(i = a; i < c; i++)
    printf("%d ",s[i]);
   printf("\nl:%d m:%d r:%d\n",l,mid,r);

   
  for(i = 0; i < q; i++){
    while(1){
      if(mid >= t[i]){ 
	c = b;
	b = (a + c)/2;
      }
      else {
	a = b + 1;
	b = (a + c)/2;
      }
      
      l = s[a];
      mid = s[b];
      r = s[c];
    
      for(j = a; j < c; j++)
	printf("%d ",s[j]);
      printf("\nl:%d m:%d r:%d\n",l,mid,r);
      
      if(mid == t[i]){
	count++;
	break;
      }
      if(l == r)
	break;
      else if(l < r)
	break;
    }
  }
  
  return count;
}

int main(){

  printf("%d\n",binarySearch());
  
  return 0;
}

