H, W, M = gets.split.map(&:to_i)
targets = M.times.map { gets.split.map(&:to_i) }

exists = Hash.new { |h, k| h[k] = {} }
counter_H = Hash.new(0)
counter_W = Hash.new(0)

targets.each do |y, x|
  exists[y][x] = true
  counter_H[y] += 1
  counter_W[x] += 1
end

maxH = -Float::INFINITY
cand_H = []
maxW = -Float::INFINITY
cand_W = []

counter_H.each do |y, cnt|
  if maxH < cnt
    maxH = cnt
    cand_H = [y]
  elsif maxH == cnt
    cand_H << y
  end
end

counter_W.each do |x, cnt|
  if maxW < cnt
    maxW = cnt
    cand_W = [x]
  elsif maxW == cnt
    cand_W << x
  end
end

maxV = counter_H[cand_H.first] + counter_W[cand_W.first]

cand_H.product(cand_W) do |y, x|
  if !exists[y][x]
    puts maxV
    exit
  end
end

puts maxV - 1
