N = int(eval(input()))

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

Q = int(eval(input()))

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



match_count = 0

for i in T:

    for j in S:

        if i == j:

            match_count += 1

            break



print((str(match_count)))



N = int(eval(input()))

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

Q = int(eval(input()))

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



match_count = 0

for i in T:

    if i in S:

        match_count += 1



print((str(match_count)))

N = int(eval(input()))
S = list(map(int, input().split()))
Q = int(eval(input()))
T = list(map(int, input().split()))
match_count = 0
for i in T:
    for j in S:
        if i == j:
            match_count += 1
            break
print((str(match_count)))

N = int(eval(input()))
S = list(map(int, input().split()))
Q = int(eval(input()))
T = list(map(int, input().split()))
match_count = 0
for i in T:
    if i in S:
        match_count += 1
print((str(match_count)))

-    for j in S: -        if i == j: -            match_count += 1 -            break +    if i in S: +        match_count += 1