p1 = input() p2 = input() N =input() a = [] for i in range(N): a.append(input()) P = p1+p2 S = set(a) print( P* (N - len(s)))