function main(input = "") {
    const lines = input.split("\n");
    const header = lines[0].split(" ").map((v) => (Number(v)));
    const H = header[0], W = header[1], M = header[2];

    let arrH = new Int32Array(H);
    let arrW = new Int32Array(W);
    let grid = new Set();
    for (let i = 0; i < M; i++) {
        let arr = lines[i + 1].split(" ");
        let h = arr[0] - 1, w = arr[1] - 1;
        arrH[h]++;
        arrW[w]++;
        grid.add(h * W + w);
    }

    let maxH = arrH[0];
    let idsH = [0];
    for (let i = 0; i < H; i++) {
        let v = arrH[i];
        if (maxH < v) {
            maxH = v;
            idsH = [i]
        } else if (maxH === v) {
            idsH.push(i);
        }
    }

    let maxW = arrW[0];
    let idsW = [0];
    for (let i = 0; i < W; i++) {
        let v = arrW[i];
        if (maxW < v) {
            maxW = v;
            idsW = [i]
        } else if (maxW === v) {
            idsW.push(i);
        }
    }

    for (let h = 0; h < idsH.length; h++) {
        let idh = idsH[h];
        for (let w = 0; w < idsW.length; w++) {
            let idw = idsW[w];
            if (!grid.has(idh * W + idw)) {
                return maxH + maxW;
            }
        }
    }

    return maxH + maxW - 1;
}

//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}