w = gets.to_i h = gets.to_i n = gets.to_i s_counter = Hash.new(0) k_counter = Hash.new(0) n.times do s, k = gets.split.map(&:to_i) s_counter[s] += 1 k_counter[k] += 1 end sum = 0 cross = 0 s_counter.values.each do |c| sum += h - c cross += k_counter.size - c end k_counter.values.each do |c| sum += w - c cross += s_counter.size - c end puts sum - cross / 2