h,w,m = gets.strip.split.map(&:to_i)
hary = Array.new(h,0)
wary = Array.new(w,0)
rec = []
m.times do
  hn,wn = gets.strip.split.map(&:to_i)
  rec.unshift([hn,wn])
  hary[hn-1] += 1
  wary[wn-1] += 1
end
#入力完了
maxh = hary.max
maxw = wary.max

mhx = hary.each_index.select{|i| hary[i]==maxh}
whx = wary.each_index.select{|i| wary[i]==maxw}
#列番号や行番号になる、これはともに配列
mh = mhx.map{|z| z+1}
wh = whx.map{|z| z+1}

s = maxh + maxw
#重なる点の有無で場合わけ

cnt = 0
rec.each do |x,y|
  if hary[x-1] == maxh && wary[y-1] == maxw
    cnt += 1
  end
end
if cnt >= (mh.size)*(wh.size)
  puts s-1
else
  puts s
end
#こういう書き方もできる