import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main() {
    val (H, W, M) = readIs()
    val hc = IntArray(H + 1)
    val wc = IntArray(W + 1)
    val map = mutableMapOf<Int, MutableList<Int>>()
    repeat(M) {
        val (h, w) = readIs()
        hc[h]++
        wc[w]++
        map.computeIfAbsent(h) {
            mutableListOf()
        } += w
    }

    val maxh = hc.max()!!
    val maxhh = mutableSetOf<Int>()
    hc.forEachIndexed { h, cnt ->
        if (cnt == maxh) maxhh += h
    }

    val maxw = wc.max()!!
    val maxww = mutableSetOf<Int>()
    wc.forEachIndexed { w, cnt ->
        if (cnt == maxw) maxww += w
    }

    val x = maxh + maxw
    var y = 0
    for ((h, ww) in map) {
        for (w in ww) {
            if (h in maxhh && w in maxww) y++
        }
    }
    println(if (y == maxhh.size * maxww.size) x - 1 else x)
}
