from collections import Counter p1 = int(input()) p2 = int(input()) N = int(input()) room_no = [input() for i in range(N)] count = Counter(room_no) lost_sum = [] for k,v in count.items(): if count[k] != 1: lost = (v - 1) * (p1 + p2) lost_sum.append(lost) print(sum(lost_sum))