P = int(input()) + int(input()) # 1 件あたりの損失額 reservations = set() count = 0 # 損失件数 for _ in range(int(input())): r = input() if r in reservations: count += 1 else: reservations.add(r) print(count * P)