p1 = int(input()) p2 = int(input()) r = [] ans = 0 n = int(input()) for i in range(n): R = int(input()) if R in r: ans += p1 + p2 else: r.append(R) print(ans)