N = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]


count = 0
for t in T:
    S.append(t)
    i = 0
    while t != S[i]:
        i += 1
    if i != (len(S) - 1):
        count += 1
    S.pop()
print(count)
 N = int(input()) N int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i S = [int(i) for i in input().split()] S [int(i) for i in input().split()] q = int(input()) q int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i T = [int(i) for i in input().split()] T [int(i) for i in input().split()] count = 0 count 0 for t in T:
    S.append(t)
    i = 0
    while t != S[i]:
        i += 1
    if i != (len(S) - 1):
        count += 1
    S.pop() t T S.append(t) S.append S append t i = 0 i 0 while t != S[i]:
        i += 1
     t != S[i] t S[i] S i i += 1 i 1 if i != (len(S) - 1):
        count += 1
     i != (len(S) - 1) i len(S) - 1 len(S) len S 1 count += 1 count 1 S.pop() S.pop S pop print(count) print count T = [int(i) for i in input().split()] [int(i) for i in input().split()] T count = 0 0 count i = 0 0 i q = int(input()) int(input()) q i += 1 1 i count += 1 1 count N = int(input()) int(input()) N S = [int(i) for i in input().split()] [int(i) for i in input().split()] S
N = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]


count = 0
for t in T:
    S.append(t)
    i = 0
    while t != S[i]:
        i += 1
    if i != (len(S) - 1):
        count += 1
    S.pop()
print(count)

