object Main extends App {
  val sc = new FastScanner(System.in)
  val h, w, m = sc.nextInt()
  val hw = Array.fill(m)((sc.nextInt()-1, sc.nextInt()-1))
  var bombs = hw.map{case (i, j) => i * w + j}.sorted
  val hb = Array.fill(h)(0)
  val wb = Array.fill(w)(0)
  for ((h, w) <- hw) {
    hb(h) += 1
    wb(w) += 1
  }

  def binSearch(begin: Int, end: Int, k: Int): Int = {
    if (end - begin <= 1) {
      begin
    } else {
      val m = begin + (end - begin) / 2
      if (bombs(m) >= k) binSearch(m, end, k) else binSearch(begin, m, k)
    }
  }

  val hMax = hb.max
  val wMax = wb.max
  val hMaxIndices = hb.zipWithIndex.collect{case (b, idx) if b == hMax => idx}
  val wMaxIndices = wb.zipWithIndex.collect{case (b, idx) if b == wMax => idx}
  if (hMaxIndices.length * wMaxIndices.length > m) {
  } else {
    var found = false
    for {
      hi <- hMaxIndices
      wi <- wMaxIndices
      if !found
    } {
      if (binSearch(0, m, hi * w + wi) == hi * w + wi) {
        found = true
      }
    }
    println(if (found) hb.max + wb.max else hb.max + wb.max - 1)
  }
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}
