#include <stdio.h>

int main(void)
{	 int n,i,x=0;
	 scanf("%d", &n);
    int a[n];
    for(i = 0; i<n ; i++){
      scanf("%d", &a[i]);
      }
    int left = 0;
    int right = n;
    int mid; 
    int q;
    scanf("%d",&q);
    int b[q];
    for(i = 0; i<n ; i++){
      scanf("%d", &b[i]);
      }
     
    while(left <= right) {
        mid = (left + right) / 2;
        for(i = 0; i<n ;i++){
        if (a[mid] == b[i]) {
            x = x+1;
        } else if (a[mid] < b[i]) {
            left = mid + 1;
        } else {
            right = mid - 1;
        }
        }
    }
    printf("%d\n", &x);
    return 0;
}