fun list() = readLine()!!.split(" ").map {it.toInt()}

fun main() {
	val (h,w,m) = list()
	val r = IntArray(h) {0}
	val c = IntArray(w) {0}

	val a = Array(m) {
		val (y,x) = list()
		++r[y-1]
		++c[x-1]
		y-1 to x-1
	}

	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)
}
