P1 = input() P2 = input() N = input() R=[] for i in range(0,N): R.append(input()) print (P1+P2)*(len(R)-len(set(R)))