import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

val dx = arrayOf(0,1,0,-1)
val dy = arrayOf(1,0,-1,0)

fun abc000X() {
	val (h,w,m) = list()
	val a = mutableSetOf<Pair<Int,Int>>()
	for(i in 1..m) {
		val (y,x) = list()
		a.add(y-1 to x-1)
	}

	val r = IntArray(h) {0}
	val c = IntArray(w) {0}

	for((x,y) in a) {
		++r[x]
		++c[y]
	}

	val rm = r.max()!!
	val cm = c.max()!!

	val rc = (0 until h).count {r[it]==rm}
	val cc = (0 until w).count {c[it]==cm}

	val t = rc.toLong()*cc
	val u = a.count {(y,x)-> r[y]==rm&&c[x]==cm}.toLong()
	println(if(t==u) rm+cm-1 else rm+cm)
}
