fun main() {
    val (H, W, m) = readLine()!!.split(' ').map { it.toInt() }

    val hs = Array(H + 1) { mutableSetOf<Int>() }
    val ws = Array(W + 1) { mutableSetOf<Int>() }

    for (i in 0 until m) {
        val (h, w) = readLine()!!.split(' ').map { it.toInt() }
        hs[h].add(w)
        ws[w].add(h)
    }

    val mh = hs.map { it.size }.max()!!
    val mhs = hs.filter { it.size == mh }

    val mw = ws.map { it.size }.max()!!
    val mws = ws.withIndex()
            .filter { (i, v) -> v.size == mw }
            .map { (i, v) -> i }

    var ans = mh + mw - 1
    for (i in mhs.indices) {
        for (j in mws.indices) {
            if (!mhs[i].contains(mws[j])) {
                ans = mh + mw
                break
            }
        }
        if (ans == mh + mw) break
    }
    println(ans)
}
