H,W,M = gets.split.map(&:to_i)
ht = Hash.new(0)
wt = Hash.new(0)
tbl = {}
M.times do
  bh,bw = gets.split.map(&:to_i)
  ht[bh] += 1
  wt[bw] += 1
  (tbl[bh]||={})[bw]=1
end
mh = ht.values.max
ht = ht.select{|k,v|v==mh}.keys
mw = wt.values.max
wt = wt.select{|k,v|v==mw}.keys
pos = ht.product(wt)
puts mh + mw - (pos.find{|h,w|!tbl[h][w]} ? 0 : 1)