P1 = int(input()) P2 = int(input()) N = int(input()) l = [] count = 0 for i in range(N): room = input() if room in l: count += 1 l.append(room) print ((P1+P2)*count)