#include<stdio.h>
#define SMAX 100000
#define TMAX 50000

main(){
  int i,j,n,q,count = 0;
  int S[SMAX],T[TMAX];
  int left = 0,right,mid;
  
  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]);
  }
  
  right = n;
  while(left < right){
    mid = (left + right)/2;
    if(S[j] == T[mid]){
      count++;
      break;
    }
    else if(S[j] > T[mid]) left = mid + 1;
    else if(S[j] < T[mid]) right = mid;
  }

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