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

yc = Hash.new(0)
xc = Hash.new(0)

t = Array.new(h) { Array.new(w, false) }

my = 0
mx = 0
m.times do
  y, x = gets.chomp.split.map(&:to_i)
  y -= 1
  x -= 1
  yc[y] += 1
  xc[x] += 1
  t[y][x] = true

  my = yc[y] if my < yc[y]
  mx = xc[x] if mx < xc[x]
end

ty = yc.filter {|k, v| v == my}
tx = xc.filter {|k, v| v == mx}

def res(t, ty, tx, my, mx, m)
  if ty.size * tx.size > m
    return mx + my
  else
    ty.keys.each do |y|
      tx.keys.each do |x|
        if t[y][x] == false
          return mx + my
        end
      end
    end

    return mx + my - 1
  end
end

puts res(t, ty, tx, my, mx, m)
