import sys





def binary_search(a, t, n):

    low = 0

    high = n - 1

    while low <= high:

        mid = (high + low) // 2

        if a[mid] == t:

            return True

        elif a[mid] < t:

            low = mid + 1

        else:

            high = mid - 1

    return False





def main():

    n = int(sys.stdin.readline())

    s = [int(x) for x in sys.stdin.readline().split()]

    q = int(sys.stdin.readline())

    t = [int(x) for x in sys.stdin.readline().split()]

    cnt = 0



    for i in t:

        if binary_search(s, i, n):

            cnt += 1

    print(cnt)





if __name__ == '__main__':

    main()
import sys



n = eval(input())

s = set([x for x in sys.stdin.readline().split()])

q = eval(input())

t = set([x for x in sys.stdin.readline().split()])

print((len(s & t)))
import sys


def binary_search(a, t, n):
    low = 0
    high = n - 1
    while low <= high:
        mid = (high + low) // 2
        if a[mid] == t:
            return True
        elif a[mid] < t:
            low = mid + 1
        else:
            high = mid - 1
    return False


def main():
    n = int(sys.stdin.readline())
    s = [int(x) for x in sys.stdin.readline().split()]
    q = int(sys.stdin.readline())
    t = [int(x) for x in sys.stdin.readline().split()]
    cnt = 0
    for i in t:
        if binary_search(s, i, n):
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

import sys

n = eval(input())
s = set([x for x in sys.stdin.readline().split()])
q = eval(input())
t = set([x for x in sys.stdin.readline().split()])
print((len(s & t)))

- -def binary_search(a, t, n): -    low = 0 -    high = n - 1 -    while low <= high: -        mid = (high + low) // 2 -        if a[mid] == t: -            return True -        elif a[mid] < t: -            low = mid + 1 -        else: -            high = mid - 1 -    return False - - -def main(): -    n = int(sys.stdin.readline()) -    s = [int(x) for x in sys.stdin.readline().split()] -    q = int(sys.stdin.readline()) -    t = [int(x) for x in sys.stdin.readline().split()] -    cnt = 0 -    for i in t: -        if binary_search(s, i, n): -            cnt += 1 -    print(cnt) - - -if __name__ == "__main__": -    main() +n = eval(input()) +s = set([x for x in sys.stdin.readline().split()]) +q = eval(input()) +t = set([x for x in sys.stdin.readline().split()]) +print((len(s & t)))