#include<stdio.h>

int main()
{
  int n, m, S[100000], T[50000], data[100000], i, j, count;
  count = 0;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }
  
  scanf("%d", &m);
  for(i = 0; i < m; i++){
    scanf("%d", &T[i]);
  }
  
  data[0] = S[0];
  j = 0;
  for(i = 1; i < n; i++){
    if(data[j] != S[i]){
      data[j] = S[i];
      j++;
    }
  }
  
  n = j+1;

  count = 0;
  
  for(i = 0; i < n; i++){
    if(S[i] != -1){
      for(j = 0; j < m; j++){
        if(S[i] == T[j]){
          count++;
        }
      }
    }
  }

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