h,w,m, = gets.split.map(&:to_i)
subject = readlines.map{|line| line.split.map(&:to_i)}
hh = Array.new(h,0)
ww = Array.new(w,0)
haha = Hash.new(0)
subject.each do |i|
  hh[i[0]-1] += 1
  ww[i[1]-1] += 1
  haha[[i[0]-1,i[1]-1]] = 1
end
k = hh.max
l = ww.max
hhh = []
www = []
for x in 0..(h-1)
  hhh << x if hh[x] == k
end
for y in 0..(w-1)
  www << y if ww[y] == l
end
hs = hhh.size
ws = www.size
for x in 0..(hs-1)
  for y in 0..(ws-1)
    hx = hhh[x]
    wy = www[y]
    if haha[[hx,wy]] == 0
      puts k+l
      exit
    end
  end
end
puts k+l-1