local c = tonumber(io.stdin:read("*l")) + tonumber(io.stdin:read("*l")) local n = tonumber(io.stdin:read("*l")) local t,r = {},0 for i=1,n do local s = io.stdin:read("*l") if t[s] == nil then t[s] = true else r = r + c end end print(r)