fun main() {
    val (h, w, m) = readInts()

    val cols = IntArray(h + 1)
    val rows = IntArray(w + 1)
    val occurrences = mutableSetOf<Pair<Int, Int>>()
    repeat(m) {
        val (x, y) = readInts()
        cols[x]++
        rows[y]++
        occurrences.add(Pair(x, y))
    }

    val maxCol = cols.max()!!
    val maxRow = rows.max()!!

    val maxColumns = cols.mapIndexed { index, value -> Pair(index, value) }.filter { pair -> pair.second == maxCol }.map { it.first }
    val maxRows = rows.mapIndexed { index, value -> Pair(index, value) }.filter { pair -> pair.second == maxRow }.map { it.first }

    val colSet = maxColumns.toMutableSet()
    val rowSet = maxRows.toMutableSet()

    var allPairs = colSet.size * rowSet.size
    occurrences.forEach { pair ->
        if (colSet.contains(pair.first) && rowSet.contains(pair.second)) allPairs--
    }

    if (allPairs == 0) println(maxCol + maxRow - 1)
    else println(maxCol + maxRow)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
