P = sum([int(input()) for _ in range(2)]) N = int(input()) b = [] ans = 0 for i in range(N): r = input() if r in b: ans += P else: b.append(r) print(ans)