class Calc0011 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @w = args.shift.first.to_i @h = args.shift.first.to_i @n = args.shift.first.to_i @cards = args.map { |l| l.map(&:to_i) } end def run ws = @cards.map(&:first).uniq.size hs = @cards.map(&:last).uniq.size ws * @h + hs * @w - ws * hs - @cards.size end end puts Calc0011.new(STDIN.readlines).run if __FILE__ == $0