def main():
    n = int(stdinput())
    S = [*map(int, stdinput().split())]
    q = int(stdinput())
    T = [*map(int, stdinput().split())]

    S = sorted(S)
    T = sorted(T)

    i = j = c = 0

    while i < n and j < q:
        if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
    print(c)

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()') def main():
    n = int(stdinput())
    S = [*map(int, stdinput().split())]
    q = int(stdinput())
    T = [*map(int, stdinput().split())]

    S = sorted(S)
    T = sorted(T)

    i = j = c = 0

    while i < n and j < q:
        if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
    print(c) main n = int(stdinput()) n int(stdinput()) int stdinput() stdinput S = [*map(int, stdinput().split())] S [*map(int, stdinput().split())] *map(int, stdinput().split()) map(int, stdinput().split()) map int stdinput().split() ().split () stdinput split q = int(stdinput()) q int(stdinput()) int stdinput() stdinput T = [*map(int, stdinput().split())] T [*map(int, stdinput().split())] *map(int, stdinput().split()) map(int, stdinput().split()) map int stdinput().split() ().split () stdinput split S = sorted(S) S sorted(S) sorted S T = sorted(T) T sorted(T) sorted T i = j = c = 0 i 0 = j = c = 0 j 0 c while i < n and j < q:
        if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
     i < n and j < q i < n i n j < q j q if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
     S[i] == T[j] S[i] S i T[j] T j c += 1 c 1 i += 1 i 1 j += 1 j 1 elif S[i] > T[j]:
            j += 1
         S[i] > T[j] S[i] S i T[j] T j j += 1 j 1 i += 1 i 1 print(c) print c def stdinput():
    from sys import stdin
    return stdin.readline().strip() stdinput from sys import stdin return stdin.readline().strip() stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()') __name__ == '__main__' __name__ '__main__' main() main def main():
    n = int(stdinput())
    S = [*map(int, stdinput().split())]
    q = int(stdinput())
    T = [*map(int, stdinput().split())]

    S = sorted(S)
    T = sorted(T)

    i = j = c = 0

    while i < n and j < q:
        if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
    print(c) def main():
    n = int(stdinput())
    S = [*map(int, stdinput().split())]
    q = int(stdinput())
    T = [*map(int, stdinput().split())]

    S = sorted(S)
    T = sorted(T)

    i = j = c = 0

    while i < n and j < q:
        if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
    print(c) main def stdinput():
    from sys import stdin
    return stdin.readline().strip() def stdinput():
    from sys import stdin
    return stdin.readline().strip() stdinput
def main():
    n = int(stdinput())
    S = [*map(int, stdinput().split())]
    q = int(stdinput())
    T = [*map(int, stdinput().split())]

    S = sorted(S)
    T = sorted(T)

    i = j = c = 0

    while i < n and j < q:
        if S[i] == T[j]:
            c += 1
            i += 1
            j += 1
        elif S[i] > T[j]:
            j += 1
        else:
            i += 1
    
    print(c)

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')
