def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    cnt = 0
    for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()
 def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    cnt = 0
    for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

    print(cnt) main n = int(input()) n int(input()) int input() input s = list(map(int, input().split())) s list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split q = int(input()) q int(input()) int input() input t = list(map(int, input().split())) t list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

     et t sc = s.copy() sc s.copy() s.copy s copy sc.append(et) sc.append sc append et i = 0 i 0 while sc[i] != et:
            i += 1

         sc[i] != et sc[i] sc i et i += 1 i 1 if i < n:
            cnt += 1

     i < n i n cnt += 1 cnt 1 print(cnt) print cnt if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    cnt = 0
    for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

    print(cnt) def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    cnt = 0
    for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

    print(cnt) main
def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    cnt = 0
    for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()

