object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datH,datW,datM) = readLine.split(" ").map(_.toInt)
    val datS = for (i <- 1 to datM) yield {
      val Array(datY,datX) = readLine.split(" ").map(_.toInt)
      (datY - 1, datX - 1)
    }

    // initialize
    var aryH = new Array[Int](datH)
    // for (i <- 0 until aryH.length) aryH(i) = 0 // default 0
    var aryW = new Array[Int](datW)
    // for (i <- 0 until aryW.length) aryW(i) = 0 // default 0

    // counting
    datS.map{a => aryH(a._1) += 1; aryW(a._2) += 1}
    val maxH = aryH.max
    val maxW = aryW.max

    // [[crossing check]]
    // get candidate row/col idx
    val candH = aryH.zipWithIndex.filter(a => a._1 == maxH).map(a => a._2)
    val candW = aryW.zipWithIndex.filter(a => a._1 == maxW).map(a => a._2)

    // init matrix
    var aryM = Array.ofDim[Boolean](datH, datW)
    // for(i <- 0 until datH; j <- 0 until datW) aryM(i)(j) = 0 //default 0
    // make matrix
    datS.map{a => aryM(a._1)(a._2) = true}

    // cross check
    val valCross = candH.map{y =>
      candW.map{x =>
        aryM(y)(x)
      }
    }.flatten.exists(_ == false)

    val ans = maxH + maxW - (if(valCross) 0 else 1)
    println(ans)
  }
}
