fun main(args : Array<String>) {
    val (h, w, m) = readLine()!!.split(" ").map { it.toInt() }
    val hasBomb = mutableMapOf<Pair<Int, Int>, Boolean>()
    val hBombs = IntArray(h) {0}
    val wBombs = IntArray(w) {0}

    repeat(m) {
        val (bh, bw) = readLine()!!.split(" ").map { it.toInt()-1 }
        hasBomb[Pair(bh, bw)] = true
        hBombs[bh]++
        wBombs[bw]++
    }

    val hMax = hBombs.max()!!
    val wMax = wBombs.max()!!
    val hIndexes = hBombs.withIndex().filter { it.value == hMax }.map { it.index }
    val wIndexes = wBombs.withIndex().filter { it.value == wMax }.map { it.index }

    hIndexes.forEach { hIdx ->
        wIndexes.forEach { wIdx ->
            if (hasBomb[Pair(hIdx, wIdx)] != true) {
                println(hMax+wMax)
                return
            }
        }
    }

    println(hMax+wMax-1)
}