#include<stdio.h>

int S[100000], T[50000];

int main(){
    //??\???
    int n, q= 0;
    scanf("%d",&n);
    printf("%d\n",n);
    for(int i = 0; i < n; i++){
        scanf("%d",&S[i]);
        printf("%d ",S[i]);
    }//S??????????????????????????????
    printf("\n");
    scanf("%d",&q);
    printf("%d\n",q);
    for(int j = 0; j < q; j++){
        scanf("%d",&T[j]);
        printf("%d ",T[j]);
    }//T??????????????????????????????
    
    //??????????????????
    int mid, C = 0;
    for(int k = 0; k < q; k++){
        int  left = 0, right = n-1;
        int key = T[k];
        while(left <= right){
            if(left == right){
                if(S[left] == key){C++;}
                break;
            } //???????????????????????????????????§???????????¨?????¨???
            else{
                mid = (left + right)/2;
                if(S[mid] == key){C++;} //key??¨?????????S???????´?????????????????????????C???1?¢???????
                else{
                    if(S[left] < key){left = mid + 1;} //key???S[mid]????????§???????????°?????????left???mid?????????????¨??????????????????????mid????????´??§while??????????????????
                    else {right = mid;}//?????¨????§?
                }
            }
        }
    }
    printf("%d\n",C);
    return 0;
}