import scala.io.StdIn._
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val H, W, M = in.nextInt
  val rows = new Array[Int](H + 1)
  val cols = new Array[Int](W + 1)

  val ts = Array.fill(M){
    val x = in.nextInt
    val y = in.nextInt
    rows(y) += 1
    cols(x) += 1
    (x, y)
  }

  val rMax = rows.max
  val tRows = rows.count(_ == rMax)
  val cMax = cols.max
  val tCols = cols.count(_ == cMax)
  val targetBomb = ts.count(t => rows(t._2) == rMax && cols(t._1) == cMax) == tRows * tCols
  println(rMax + cMax - (if (targetBomb) 1 else 0))
}