import numpy as np
import sys

readline = sys.stdin.readline

N = int(input())
A = np.array(readline().split(), np.int64)
Q = int(input())
BC = np.array([np.array(readline().split(), np.int64) for n in range(Q)], np.int64)
# BC[N][0,1]

print(N)

"""
for q in range(Q):
    A = [BC[q][1] if x==BC[q][0] else x for x in A]
    print(sum(A))
    """