H,W,M = gets.split.map(&:to_i)
hh,ww,hw = [0]*H,[0]*W,[nil]*H
M.times{
	h,w = gets.split.map{|_|_.to_i-1}
	hh[h] += 1
	ww[w] += 1
	(hw[h]||=[false]*W)[w] = true
}
f = lambda{|(x,a),(n,h)|
	next x<n ? [n,[h]] : x==n ? [x,a<<h] : [x,a]
}
hx,ha = hh.each_with_index.inject([0,[]],&f)
wx,wa = ww.each_with_index.inject([0,[]],&f)
p hx+wx-(ha.product(wa).all?{|h,w|hw[h]&.[](w)} ? 1 : 0)
