#include <stdio,h>
#define MAX 10000

int main()
{
  int l, r, m, n, S[MAX], q, T[MAX], i, j, c = 0;

  
  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]);

  r = n;

  while(l > r){
    i = 0;
    m = (l + r) % 2;
    if(A[m] == T[i]){
      c++;
      break;
    }

    else if(T[i]< A[m]) r = m;
    else l = mid + 1;
    
    i++;
  }

  printf("%d" c);

  return 0;
}