const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
let [H, W, M] = lines[0].split(' ').map(Number)

const h = Array(H + 1).fill().map((_, i) =>  [0, i])
const w = Array(W + 1).fill().map((_, i) =>  [0, i])

const b = {}

for (let i = 1; i <= M; i++) {
    const p = lines[i].split(' ').map(Number)
    h[p[0]][0]++
    w[p[1]][0]++
    b[p[0] + ':' + p[1]] = 1
}

h.sort((a, b) => b[0] - a[0])
w.sort((a, b) => b[0] - a[0])

const hm = h[0][0]
const hp = []
for (let i = 0; i <= H; i++) {
    if (h[i][0] === hm) {
        hp.push(h[i][1])
    } else {
        break
    }
}

const wm = w[0][0]
const wp = []
for (let i = 0; i <= H; i++) {
    if (w[i][0] === wm) {
        wp.push(w[i][1])
    } else {
        break
    }
}

let c = 1
for (let i = 0; i < hp.length; i++) {
    for (let j = 0; j < wp.length; j++) {
        const index = hp[i] + ':' + wp[j]
        if (!b[index]) {
            c = 0
            break
        }
    }
    if (c === 0) break
}
console.log(hm + wm - c)
