#include<stdio.h>

int main(){

  int S1[10000],S[10000],T[500],count=0,n,q,i,j,left,mid,right,key;

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

  for(i=0,j=0;i<n;i++){
    if(S1[i]!=S1[i+1]){
      S[j]=S1[i];
      j++;
    }
  }

  n=j+1;

  scanf("%d",&q);
  for(i=0;i<q;i++) 
    scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    key=T[i];
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(key==S[mid]){
	count++;
	break;
      }
      else if(key>S[mid])left=mid+1;
      else right=mid;
    }
  }

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

    return 0;
  }