# https://atcoder.jp/contests/abc176/tasks/abc176_e

h,w,m=gets.split.map(&:to_i)
# h,w,m=300000,300000,300000
lh=[0]*h
lw=[0]*w
# s=[]
# h.times do
#   s << [0]*w
# end
sl=[]
m.times do
# m.times do |i|
  hh,ww=gets.split.map(&:to_i)
  # hh,ww=i+1,i+1
  lh[hh-1]+=1
  lw[ww-1]+=1
  # s[hh-1][ww-1]=1
  sl << [hh-1,ww-1]
end
mh=lh.max
mw=lw.max
# lhh=[]
# lh.each.with_index do |llh,i|
#   if llh==mh
#     lhh << i
#   end
# end
# lww=[]
# lw.each.with_index do |llw,i|
#   if llw==mw
#     lww << i
#   end
# end
# ans=mh+mw
# lhh.each do |i|
#   lww.each do |j|
#     if s[i][j]==0
#       puts ans
#       exit
#     end
#   end
# end
ans=mh+mw
ch=lh.count(mh)
cw=lw.count(mw)
cnt=ch*cw
sl.each do |i,j|
  if lh[i]==mh&&lw[j]==mw
    cnt-=1
  end
end
puts cnt==0 ? ans-1 : ans
