def binary_search(l, t):

    left = 0

    right = len(l) - 1



    while left <= right:

        mid = (left + right)//2

        if l[mid] < t:

            left = mid + 1

        elif t < l[mid]:

            right = mid - 1

        else:

            return True



def main():

    n = int(eval(input()))

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

    q = int(eval(input()))

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



    cnt = 0

    for et in t:

        bl = binary_search(s, et)

        if bl:

            cnt += 1



    print(cnt)



if __name__ == '__main__':

    main()



def binary_search(l, t):

    left = 0

    right = len(l)



    while left < right:

        mid = (left + right)//2

        if l[mid] < t:

            left = mid + 1

        elif t < l[mid]:

            right = mid

        else:

            return True



def main():

    n = int(eval(input()))

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

    q = int(eval(input()))

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



    cnt = 0

    for et in t:

        bl = binary_search(s, et)

        if bl:

            cnt += 1



    print(cnt)



if __name__ == '__main__':

    main()



def binary_search(l, t):
    left = 0
    right = len(l) - 1
    while left <= right:
        mid = (left + right) // 2
        if l[mid] < t:
            left = mid + 1
        elif t < l[mid]:
            right = mid - 1
        else:
            return True


def main():
    n = int(eval(input()))
    s = list(map(int, input().split()))
    q = int(eval(input()))
    t = list(map(int, input().split()))
    cnt = 0
    for et in t:
        bl = binary_search(s, et)
        if bl:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

def binary_search(l, t):
    left = 0
    right = len(l)
    while left < right:
        mid = (left + right) // 2
        if l[mid] < t:
            left = mid + 1
        elif t < l[mid]:
            right = mid
        else:
            return True


def main():
    n = int(eval(input()))
    s = list(map(int, input().split()))
    q = int(eval(input()))
    t = list(map(int, input().split()))
    cnt = 0
    for et in t:
        bl = binary_search(s, et)
        if bl:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

-    right = len(l) - 1 -    while left <= right: +    right = len(l) +    while left < right: -            right = mid - 1 +            right = mid