#include<stdio.h>

int 
int main(){

 int a[100000],b[50000],n,m,i,j;
 int count=0;
int left,mid,left;



  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&a[i]);}

  scanf("%d",&m);
  for(j=0;j<m;j++){
   scanf("%d",&b[j]);}


    for(i=0;i<n;i++){
       left=0;
       right=n;
       mid=(left+right)/2;
if(a[mid]==b[i]){count++;
break;
}
else if(a[mid]<b[i]){
right=mid+1;}
else{
right=mid-1;
}
}
 printf("%d\n",count);
 return 0;
}