a = int(input()) b = int(input()) num = int(input()) count = 0 lst = [] for i in range(num): rm = input() if rm in lst: count += 1 lst.append(rm) print((a+b)*count)