#!ruby --jit
require "set"

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

hs = [0] * h
ws = [0] * w
vs = Set.new

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

hmax = hs.max
wmax = ws.max

max = 0
(0...h).each do |i|
  next unless hs[i] == hmax
  (0...w).each do |j|
    next unless ws[j] == wmax
    unless vs.include? i*w+j
      p hmax + wmax
      exit
    end
  end
end

p hmax + wmax - 1