h, w, m = gets.chomp.split.map(&:to_i)
xys = Hash.new(0)
rows = Hash.new(0)
cols = Hash.new(0)

m.times do |i|
  hi, wi = gets.chomp.split.map(&:to_i)
  rows[hi] += 1
  cols[wi] += 1
  xys[[hi, wi]] += 1
end

rx = rows.to_a.sort_by! {|_, v| v }
ry = cols.to_a.sort_by! {|_, v| v }

i = rx.size - 1
j = ry.size - 1
res = rx[i][1] + ry[j][1] - xys[[rx[i][0], ry[j][0]]]
while (i > 0 || j > 0) && res <= rx[i][1] + ry[j][1] - xys[[rx[i][0], ry[j][0]]]
  if i > 0 && rx[i][1] == rx[i - 1][1]
    i -= 1
  elsif j > 0 && ry[j][1] == ry[j - 1][1]
    j -= 1
  else
    break
  end

  if xys[[rx[i][0], ry[j][0]]] == 0
    res += 1
    break
  end
end

if xys[[rx[i][0], ry[j][0]]] == 0
  res += 1
end
puts res