#include<stdio.h>


int main(){

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

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

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