H,W,M=gets.split.map(&:to_i)
B=M.times.map{gets.split.map{|i|i.to_i-1}}

cnth=[0]*H
cntw=[0]*W
maxh=maxw=0
B.each do |h,w|
  maxh=[maxh,cnth[h]+=1].max
  maxw=[maxw,cntw[w]+=1].max
end

nh=nw=0
vh=*vw=[]
H.times do |h|
  next unless cnth[h]==maxh
  nh+=1
  vh[h]=true
end
W.times do |w|
  next unless cntw[w]==maxw
  nw+=1
  vw[w]=true
end

ne=B.count{|h,w|vh[h]&&vw[w]}

p nh*nw==ne ? maxh+maxw-1 : maxh+maxw
