from typing import Set, List


def linear_search_v1(S: List[int], key: int) -> int:
    for num in S:
        if num == key:
            return 1
    return 0


def linear_search_v2(S: List[int], key: int) -> int:
    i: int = 0
    S.append(key)

    while S[i] != key:
        i += 1

    if i != len(S) - 1:
        return 1
    else:
        return 0


def main_v1():
    _ = input()
    S: List[int] = list(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        # count += linear_search_v1(S, num)
        count += linear_search_v2(S[:], num)

    print(count)


def main_v2():
    _ = input()
    S: Set[int] = set(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        if num in S:
            count += 1

    print(count)


if __name__ == "__main__":
    main_v2()
 from typing import Set, List def linear_search_v1(S: List[int], key: int) -> int:
    for num in S:
        if num == key:
            return 1
    return 0 linear_search_v1 for num in S:
        if num == key:
            return 1
     num S if num == key:
            return 1
     num == key num key return 1 1 return 0 0 S: List[int] S key: int key def linear_search_v2(S: List[int], key: int) -> int:
    i: int = 0
    S.append(key)

    while S[i] != key:
        i += 1

    if i != len(S) - 1:
        return 1
    else:
        return 0 linear_search_v2 i: int = 0 i 0 S.append(key) S.append S append key while S[i] != key:
        i += 1

     S[i] != key S[i] S i key i += 1 i 1 if i != len(S) - 1:
        return 1
    else:
        return 0 i != len(S) - 1 i len(S) - 1 len(S) len S 1 return 1 1 return 0 0 S: List[int] S key: int key def main_v1():
    _ = input()
    S: List[int] = list(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        # count += linear_search_v1(S, num)
        count += linear_search_v2(S[:], num)

    print(count) main_v1 _ = input() _ input() input S: List[int] = list(map(int, input().split())) S list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split _ = input() _ input() input T: List[int] = list(map(int, input().split())) T list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split count: int = 0 count 0 for num in T:
        # count += linear_search_v1(S, num)
        count += linear_search_v2(S[:], num)

     num T count += linear_search_v2(S[:], num) count linear_search_v2(S[:], num) linear_search_v2 S[:] S : num print(count) print count def main_v2():
    _ = input()
    S: Set[int] = set(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        if num in S:
            count += 1

    print(count) main_v2 _ = input() _ input() input S: Set[int] = set(map(int, input().split())) S set(map(int, input().split())) set map(int, input().split()) map int input().split() ().split () input split _ = input() _ input() input T: List[int] = list(map(int, input().split())) T list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split count: int = 0 count 0 for num in T:
        if num in S:
            count += 1

     num T if num in S:
            count += 1

     num in S num S count += 1 count 1 print(count) print count if __name__ == "__main__":
    main_v2() __name__ == "__main__" __name__ "__main__" main_v2() main_v2 def main_v2():
    _ = input()
    S: Set[int] = set(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        if num in S:
            count += 1

    print(count) def main_v2():
    _ = input()
    S: Set[int] = set(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        if num in S:
            count += 1

    print(count) main_v2 def linear_search_v1(S: List[int], key: int) -> int:
    for num in S:
        if num == key:
            return 1
    return 0 def linear_search_v1(S: List[int], key: int) -> int:
    for num in S:
        if num == key:
            return 1
    return 0 linear_search_v1 def linear_search_v2(S: List[int], key: int) -> int:
    i: int = 0
    S.append(key)

    while S[i] != key:
        i += 1

    if i != len(S) - 1:
        return 1
    else:
        return 0 def linear_search_v2(S: List[int], key: int) -> int:
    i: int = 0
    S.append(key)

    while S[i] != key:
        i += 1

    if i != len(S) - 1:
        return 1
    else:
        return 0 linear_search_v2 def main_v1():
    _ = input()
    S: List[int] = list(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        # count += linear_search_v1(S, num)
        count += linear_search_v2(S[:], num)

    print(count) def main_v1():
    _ = input()
    S: List[int] = list(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        # count += linear_search_v1(S, num)
        count += linear_search_v2(S[:], num)

    print(count) main_v1
from typing import Set, List


def linear_search_v1(S: List[int], key: int) -> int:
    for num in S:
        if num == key:
            return 1
    return 0


def linear_search_v2(S: List[int], key: int) -> int:
    i: int = 0
    S.append(key)

    while S[i] != key:
        i += 1

    if i != len(S) - 1:
        return 1
    else:
        return 0


def main_v1():
    _ = input()
    S: List[int] = list(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        # count += linear_search_v1(S, num)
        count += linear_search_v2(S[:], num)

    print(count)


def main_v2():
    _ = input()
    S: Set[int] = set(map(int, input().split()))
    _ = input()
    T: List[int] = list(map(int, input().split()))
    count: int = 0

    for num in T:
        if num in S:
            count += 1

    print(count)


if __name__ == "__main__":
    main_v2()

