#!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 }

hc_max = hcs[0][1]
k1 = (0...hcs.size).bsearch { |i| hcs[i][1] < hc_max } || hcs.size-1

wc_max = wcs[0][1]
l1 = (0...wcs.size).bsearch { |j| wcs[j][1] < wc_max } || wcs.size-1

max = 0
(0..k1).each do |k|
  i, c = hcs[k]
  (0..l1).each do |l|
    j, d = wcs[l]
    cnt = c + d
    cnt -= 1 if vs.include? i*w+j
    max = cnt if max < cnt
  end
end

p max
