#include <stdio.h>

int main(){
  int n,q,C;
  int i,j;
  int count=0,scount=0;

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

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

  int left=S[0];
  int right=S[n];
  int mid;

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

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

  return 0;

}

