# coding: utf-8 # Your code here! hotel = {} h1 = int(input()) h2 = int(input()) n = int(input()) for i in range(n): r = input() if r not in hotel: hotel[r] = 1 else: hotel[r] += 1 loss = 0 for key, value in hotel.items(): if value >= 2: loss += value - 1 print((h1 + h2) * loss)