# frozen_string_literal: true

h, w, m = gets.split.map(&:to_i)
hw = m.times.map { gets.split.map(&:to_i) }

hh = Hash.new { false }
hi = Hash.new { 0 }
hj = Hash.new { 0 }

hw.each do |e|
  x = e[0]
  y = e[1]
  hh[[x, y]] = true
  hi[x] += 1
  hj[y] += 1
end

a = hi.to_a
b = hj.to_a

aa = a.max_by { |e| e[1] }
bb = b.max_by { |e| e[1] }

aaa = a.filter { |e| e[1] == aa[1] }
bbb = b.filter { |e| e[1] == bb[1] }
flag = true
aaa.each do |xx|
  bbb.each do |yy|
    x = xx[0]
    y = yy[0]
    flag = false unless hh[[x, y]]
  end
end
ans = aa[1] + bb[1]
ans -= 1 if flag
puts ans
