
import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    //val (H, M, W) = readLine()!!.split(" ").map{ it.toInt() }
    val H = reader.nextInt()
    val M = reader.nextInt()
    val W = reader.nextInt()

    /*val map = Array(H){
        val rows = IntArray(M)
        rows.fill(0)
        rows
    }*/
    val positionArray = mutableListOf<Pair<Int, Int>>()
    
    var maxRowNum = 0
    var maxRowCount = 0L
    //var rowNoList = mutableListOf<Int>()
    val maxRows = IntArray(H)
    maxRows.fill(0)
    
    val rowNums = IntArray(H)
    rowNums.fill(0)

    var maxColumnNum = 0
    var maxColumnCount = 0L
    //var columnNoList = mutableListOf<Int>()
    val maxColumns = IntArray(M)
    maxColumns.fill(0)
    
    val columnNums = IntArray(M)
    columnNums.fill(0)

    repeat(W){
        //val (row, column) = readLine()!!.split(" ").map { it.toInt() - 1}
        val row = reader.nextInt() - 1
        val column = reader.nextInt() - 1
        rowNums[row] += 1
        columnNums[column] += 1

        positionArray.add(Pair(row, column))

        if(rowNums[row] > maxRowNum){
            maxRowNum = rowNums[row]
        }

        if(columnNums[column] > maxColumnNum){
            maxColumnNum = columnNums[column]
        }
    }

    rowNums.forEachIndexed { index, i ->
        if(i == maxRowNum){
            //rowNoList.add(index)
            maxRows[index] = 1
            maxRowCount += 1
        }
    }

    columnNums.forEachIndexed{ index, i->
        if(i == maxColumnNum){
            //columnNoList.add(index)
            maxColumns[index] = 1
            maxColumnCount += 1
        }
    }
    
    var positionCount = 0L
    positionArray.forEach { 
        if(maxRows[it.first] == 1 && maxColumns[it.second] == 1){
            positionCount++
        }
    }
   /* for(rowIndex in 0..rowNoList.size - 1){
        for(columnIndex in 0..columnNoList.size - 1){
            var rowNum = rowNoList[rowIndex]
            var columnNum = columnNoList[columnIndex]

            if(map[rowNum][columnNum] == 0){
                findCommon = false
                break
            }
        }
        if(!findCommon){
            break
        }
    }*/
    //println("maxRowCount: ${maxRowCount} maxColumnCount: ${maxColumnCount} positionCount: ${positionCount}")
    println(if(maxRowCount * maxColumnCount <= positionCount) maxRowNum + maxColumnNum - 1 else maxRowNum + maxColumnNum)
}