H,W,M = gets.split.map(&:to_i)
hh,ww,hw = [0]*H,[0]*W,[0]*(H*W)
M.times{
	h,w = gets.split.map{|_|_.to_i-1}
	hh[h] += 1
	ww[w] += 1
	hw[h*W+w] += 1
}
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).any?{|h,w|0==hw[h*W+w]} ? 0 : 1)
