def linearSearch(key, list):

    for e in list:

        if key == e:

            return 1

    return 0





N1 = int(eval(input()))

arr1 = list(set([int(n) for n in input().split()]))

N2 = int(eval(input()))

arr2 = list(set([int(n) for n in input().split()]))



print((sum([linearSearch(key, arr2) for key in arr1])))



def linearSearch(key, list):

    for e in list:

        if key == e:

            return 1

    return 0





N1 = int(eval(input()))

arr1 = [int(n) for n in input().split()]

N2 = int(eval(input()))

arr2 = [int(n) for n in input().split()]



print((sum([linearSearch(key, arr1) for key in arr2])))



def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


N1 = int(eval(input()))
arr1 = list(set([int(n) for n in input().split()]))
N2 = int(eval(input()))
arr2 = list(set([int(n) for n in input().split()]))
print((sum([linearSearch(key, arr2) for key in arr1])))

def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


N1 = int(eval(input()))
arr1 = [int(n) for n in input().split()]
N2 = int(eval(input()))
arr2 = [int(n) for n in input().split()]
print((sum([linearSearch(key, arr1) for key in arr2])))

-arr1 = list(set([int(n) for n in input().split()])) +arr1 = [int(n) for n in input().split()] -arr2 = list(set([int(n) for n in input().split()])) -print((sum([linearSearch(key, arr2) for key in arr1]))) +arr2 = [int(n) for n in input().split()] +print((sum([linearSearch(key, arr1) for key in arr2])))