# 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|
  h = e[0]
  w = e[1]
  hh[[h, w]] = true
  hi[h] += 1
  hj[w] += 1
end

a = hi.to_a
b = hj.to_a

aa = a.map(&:first)
bb = b.map(&:first)
max = 0
aa.product(bb).each do |e|
  c = hi[e[0]] + hj[e[1]]
  c -= 1 if hh[[e[0], e[1]]]
  max = c if max < c
end
puts max
