#include <stdio.h>
#include <stdlib.h>

int main() {
  int numberN1,size1,numberN2,size2,i,j,k,count1,count2;
  int* sequenceArray1;
  int* sequenceArray2;
  int array[1000];

  scanf("%d", &numberN1);
  sequenceArray1 = malloc(sizeof(int) * numberN1);
  for(i=0; i<numberN1; i++) {
    scanf("%d", sequenceArray1+i );
  }

  scanf("%d", &numberN2);
  sequenceArray2 = malloc(sizeof(int) * numberN2);
  for(i=0; i<numberN2; i++) {
    scanf("%d", sequenceArray2+i );
  }

  for(i=0; i<numberN1; i++) {
    for(j=0; j<numberN2; j++) {
      if( *(sequenceArray1+i) == *(sequenceArray2+j) ) {
        count1++;
        for(k=0; k<count1+1; k++) {
          if(*(sequenceArray2+j) == array[k]) {
            array[k]= *(sequenceArray2+j);
            count2++;
          }
        }
      }
    }
  }
  printf("%d\n", count2);

  return 0;
}