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 c: if c[hotel] >= 2: a = c[hotel] - 1 price += (a* yuki_Hotel) + (a * next_Hotel) print(price)