(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    const lines = input.split(/\n/);
    const [h, w, m] = lines[0].split(/\s/).map(v => +v);
    const targets = lines.slice(1, m + 1).map(line => line.split(/\s/).map(v => v - 1));

    let targetCount = [new Array(h).fill(0), new Array(w).fill(0)];
    let targetMap = new Array(h).fill([]).map(x => new Array(w).fill(false));
    for (const target of targets) {
        targetCount[0][target[0]]++;
        targetCount[1][target[1]]++;
        targetMap[target[0]][target[1]] = true;
    }

    let yMaxs = [];
    let yMax = 0;
    for (let i = 0; i < h; i++) {
        if(targetCount[1][i] < yMax) continue;
        if(targetCount[1][i] == yMax){
            yMaxs.push(i);
        }else{
            yMax = targetCount[1][i];
            yMaxs = [i];
        }
    }
    let allCross = 1;
    let xMax = 0;
    for (let i = 0; i < h; i++) {
        if(targetCount[0][i] < xMax) continue;
        if(targetCount[0][i] > xMax){
            xMax = targetCount[0][i];
            allCross = 1;
        }
        for (let j = 0; j < yMaxs.length; j++) {
            if(!targetMap[i][yMaxs[j]]){
                allCross = 0;
                break;
            }
        }
    }
    console.log(yMax + xMax - allCross);
})();
