h,w,m=gets.split.map &:to_i
bs=[]
sr=[0]*h
sc=[0]*w
m.times{
  i,j=gets.split.map &:to_i
  i-=1
  j-=1
  bs.push([i,j])
  sr[i]+=1
  sc[j]+=1
}
mri=[]
mr=0
sr.each_with_index{|e,i|
  next if e<mr
  if e>mr
    mr=e
    mri.clear
  end
  mri.push(i)
}
mci=[]
mc=0
sc.each_with_index{|e,i|
  next if e<mc
  if e>mc
    mc=e
    mci.clear
  end
  mci.push(i)
}
mrh={}
mch={}
mri.each{|i| mrh[i]=true }
mci.each{|i| mch[i]=true }
#p [sr,sc,bs]
#p [mr,mc,mrh,mch]
puts mr+mc-(bs.count{|(i,j)| mrh[i]&&mch[j] }==mri.size*mci.size ? 1 : 0)