a = int(input()) a += int(input()) N = int(input()) ans = 0 s = set() for _ in range(N): r = int(inpur()) if r in s: ans += a else: s.add(r) print(ans)