import math as ma



def bs(num, li):

    low, high = 0, len(li)

    if num >= li[low] and num <= li[high-1]:

        while(low <= high):

            center = ma.floor((low + high)/2 )

            if li[center] < num:

                low = center + 1

            elif li[center] > num:

                high = center -1

            else:

                return True

                break



flag = False

cnt = 0



n = int(eval(input()))

li1 = list(map(int, input().split()))

m = int(eval(input()))

li2 = list(map(int, input().split()))



for i in li2:

    flag = bs(i, li1)

    if flag:

        cnt += 1

print(cnt)
n = int(eval(input()))

S = set(map(int, input().split()))

q = int(eval(input()))

T = list(map(int, input().split()))



sum = 0



for i in T:

    if i in S:

        sum +=1

        

print(sum)
import math as ma


def bs(num, li):
    low, high = 0, len(li)
    if num >= li[low] and num <= li[high - 1]:
        while low <= high:
            center = ma.floor((low + high) / 2)
            if li[center] < num:
                low = center + 1
            elif li[center] > num:
                high = center - 1
            else:
                return True
                break


flag = False
cnt = 0
n = int(eval(input()))
li1 = list(map(int, input().split()))
m = int(eval(input()))
li2 = list(map(int, input().split()))
for i in li2:
    flag = bs(i, li1)
    if flag:
        cnt += 1
print(cnt)

n = int(eval(input()))
S = set(map(int, input().split()))
q = int(eval(input()))
T = list(map(int, input().split()))
sum = 0
for i in T:
    if i in S:
        sum += 1
print(sum)

-import math as ma - - -def bs(num, li): -    low, high = 0, len(li) -    if num >= li[low] and num <= li[high - 1]: -        while low <= high: -            center = ma.floor((low + high) / 2) -            if li[center] < num: -                low = center + 1 -            elif li[center] > num: -                high = center - 1 -            else: -                return True -                break - - -flag = False -cnt = 0 -li1 = list(map(int, input().split())) -m = int(eval(input())) -li2 = list(map(int, input().split())) -for i in li2: -    flag = bs(i, li1) -    if flag: -        cnt += 1 -print(cnt) +S = set(map(int, input().split())) +q = int(eval(input())) +T = list(map(int, input().split())) +sum = 0 +for i in T: +    if i in S: +        sum += 1 +print(sum)