fun main(args: Array<String>) {
    val (H, W, M) = readLine()!!.split(' ').map { it.toInt() }
    val arrH = mutableMapOf<Int, Int>()
    val arrW = mutableMapOf<Int, Int>()
    val arr = mutableMapOf<Int, MutableMap<Int, Int>>()

    val pos = arrayOfNulls<Pair<Int,Int>>(M)
    arrH[0] = 0
    arrW[0] = 0

    var maxH = 0
    var maxW = 0

    repeat(M) {
        val (h, w) = readLine()!!.split(' ').map { it.toInt() }

        if (arrH[h] == null) arrH[h] = 0
        arrH[h] = arrH[h]!! + 1
        if (arrH[h]!! > arrH[maxH]!!) maxH = h

        if (arrW[w] == null) arrW[w] = 0
        arrW[w] = arrW[w]!! + 1
        if (arrW[w]!! > arrW[maxW]!!) maxW = w

        if (arr[h] == null) arr[h] = mutableMapOf()
        if (arr[h]!![w] == null) arr[h]!![w] = 0
        arr[h]!![w] = arr[h]!![w]!! + 1

        pos[it] = h to w
    }

    var d = arr[maxH] != null && arr[maxH]!![maxW] != null
    val ans = arrH[maxH]!! + arrW[maxW]!!
    if (!d) println(ans)
    else {
        val pairH = arrH.toList().sortedBy { it.second }.filter { it.second == arrH[maxH]!! }
        val pairW = arrW.toList().sortedBy { it.second }.filter { it.second == arrW[maxW]!! }

        pairH.forEach { (i, _) ->
            pairW.forEach { (j, _) ->
                d = d && (arr[i] != null && arr[i]!![j] != null)
                if (!d) {
                    println(ans)
                    return
                }
            }
        }
        println(ans - 1)
    }
}
