(H, W, M), *HWs = readlines.map{_1.split.map(&:to_i)}

ht, wt = Array.new(H + 1, 0), Array.new(W + 1, 0)
HWs.each{|h, w| ht[h] += 1; wt[w] += 1}
hm, wm = ht.max, wt.max
hn, wn = ht.count(hm), wt.count(wm)
puts hm + wm - (hn*wn > HWs.count{ht[_1] == hm && wt[_2] == wm} ? 0 : 1)