p1=int(input()) p2=int(input()) N=int(input()) a=[] for i in range(N): b=input() a.append(b) d=len(a)-len(set(a)) print((p1+p2)*d)