P1 = int(input().strip()) P2 = int(input().strip()) N = int(input().strip()) lst1 = [] lst2 = [] for i in range(N): R = input().strip() try: tmp = lst1.index(R) lst2[tmp] += 1 except: lst1.append(R) lst2.append(1) print((sum(lst2) - len(lst2)) * (P1 + P2))