import collections yuki_Hotel = int(input()) next_Hotel = int(input()) n = int(input()) Hotels = [] price = 0 for count in range(n): list = input() Hotels.append(list) c = collections.Counter(Hotels) for hotel in Hotels: if c[hotel] >= 2: price += (c[hotel] * yuki_Hotel) + (c[hotel] * next_Hotel) print(price)