#!ruby --jit
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
k = l = n = 0
while n < m+1
  i, c = wcs[k]
  j, d = wcs[l]
  cnt = c + d
  cnt -= 1 if vs.include? i*w+j
  max = cnt if max < cnt
  if n.even? and k < hcs.size
    k += 1
  elsif l < wcs.size
    l += 1
  else
    break
  end
  n += 1
end

p max
