require 'set'

h, w, m = gets.chomp.split(' ').map(&:to_i)

ch = (h + 1).times.map { 0 }
cw = (w + 1).times.map { 0 }

b = Set.new
m.times do
  t = gets.chomp.split(' ').map(&:to_i)
  ch[t[0]] += 1
  cw[t[1]] += 1
  b.add(t)
end

ch_max = ch.max
can_h = ch.map.with_index { |c, i| [c, i] }.select { |c| c[0] == ch_max }.map { |c| c[1] }

cw_max = cw.max
can_w = cw.map.with_index { |c, i| [c, i] }.select { |c| c[0] == cw_max }.map { |c| c[1] }

if can_h.length * can_w.length > m
  puts ch_max + cw_max
else
  if can_h.product(can_w).all? { |x, y| b.include?([x, y]) }
    puts ch_max + cw_max - 1
  else
    puts ch_max + cw_max
  end
end
