import scala.io.StdIn._
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val H, W, M = in.nextInt
  val ts = Array.fill(M)((in.nextInt, in.nextInt))
  def filter(map: Map[Int, Array[Int]]): (Int, Set[Int]) = {
    val max = map.values.map(_.size).max
    (max, map.filter{case (k, v) => v.size == max}.keySet)
  }

  val (rMax, rows) = filter(ts.groupMap(_._1)(_._2))
  val (cMax, cols) = filter(ts.groupMap(_._2)(_._1))
  val noCross = {
    val map = ts.groupMap(_._1)(_._2).view.mapValues(_.toSet)
    (for {
      r <- rows
      c <- cols
      if (!map(r)(c))
    } yield 1).nonEmpty
  }
  println(rMax + cMax - (if (noCross) 0 else 1))
}