require "set"

h, w, m = gets.split.map &:to_i

hs = Hash.new 0
ws = Hash.new 0
vs = Set.new

m.times do
  i, j = gets.split.map &:to_i
  hs[i] += 1
  ws[j] += 1
  vs << i*w+j
end

hcs = hs.to_a.sort_by { |(_, c)| -c }
wcs = ws.to_a.sort_by { |(_, c)| -c }

max = 0
hcs.each do |(i, c)|
  max1 = 0
  wcs.each do |(j, d)|
    cnt = c + d
    cnt -= 1 if vs.include? i*w+j
    if max1 < cnt
      max1 = cnt
    else
      break
    end
  end
  if max < max1
    max = max1
  else
    break
  end
end

p max