x,y,n,*a=$<.map &:to_i;h=Hash.new 0;a.map{|e|h[e]+=1};p h.values.map{|e|e-1}.sum*(x+y)