b=int(input())+int(input()) a=[input() for _ in [0]*int(input())] print(b*(len(a)-len(set(a))))