P1 = int(input()) P2 = int(input()) N = int(input()) count = 0 ap = [] for _ in range(N): R = input() if R in ap: count += 1 ap.append(R) print((P1+P2)*count)