p1 = int(input()) p2 = int(input()) n = int(input()) seen = set() count = 0 for _ in range(n): r = int(input()) if r in seen: count += 1 else: seen.add(r) print(count * (p1 + p2))