from collections import Counter p1 = int(input()) p2 = int(input()) n = int(input()) r = [] ans = 0 for _ in range(n): r.append(input()) counter = Counter(r) for w, c in counter.most_common(): if c > 1: ans += (c-1)*(p1+p2) print(ans)