function Main(input) {
    const lowerBound = (arr, n) => {
        let first = 0, last = arr.length - 1, middle;
        while (first <= last) {
            middle = Math.floor((first + last) / 2);
            if (arr[middle] < n) first = middle + 1;
            else last = middle - 1;
        }
        return first;
    }
    const upperBound = (arr, n) => {
        let first = 0, last = arr.length - 1, middle;
        while (first <= last) {
            middle = Math.floor((first + last) / 2);
            if (arr[middle] <= n) first = middle + 1;
            else last = middle - 1;
        }
        return first;
    }
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let H = parseInt(input[0][0], 10);
    let W = parseInt(input[0][1], 10);
    let M = parseInt(input[0][2], 10);
    let arr_hw = [];
    let arr_rowCount = Array.from({length: H}, () => []);
    let arr_colCount = Array.from({length: W}, () => []);

    for (let i = 0; i < M; i++){
        arr_hw.push(input[i + 1].map(e => parseInt(e, 10)));
        arr_rowCount[arr_hw[i][0] - 1].push(arr_hw[i][1] - 1);
        arr_colCount[arr_hw[i][1] - 1].push(arr_hw[i][0] - 1);
    }

    // console.log(arr_colCount);
    let MAXrow = 1;
    let tmpRowCandidate = [];
    for (let i = 0; i < H; i++){
        if (arr_rowCount[i].length === MAXrow) {
            tmpRowCandidate.push(i);
        }
        else if (arr_rowCount[i].length > MAXrow) {
            tmpRowCandidate = [i];
            MAXrow = arr_rowCount[i].length;
        }
    }
    let MAXcol = 1;
    let tmpColCandidate = [];
    for (let i = 0; i < W; i++){
        if (arr_colCount[i].length === MAXcol) {
            tmpColCandidate.push(i);
        }
        else if (arr_colCount[i].length > MAXcol) {
            tmpColCandidate = [i];
            MAXcol = arr_colCount[i].length;
        }
    }

    // console.log(tmpRowCandidate);
    // console.log(tmpColCandidate);

    let ans = MAXrow + MAXcol - 1;
    let count = 0;
    for (let hw of arr_hw){
        if (lowerBound(tmpRowCandidate, hw[0] - 1) !== upperBound(tmpRowCandidate, hw[0] - 1) || lowerBound(tmpColCandidate, hw[1] - 1) !== upperBound(tmpColCandidate, hw[1] - 1)){
            // console.log(hw);
            count ++;   
        }
    }
    // console.log(count);
    // console.log(MAXrow * tmpRowCandidate.length + MAXcol * tmpColCandidate.length - tmpRowCandidate.length * tmpColCandidate.length);
    if (count > (MAXrow * tmpRowCandidate.length + MAXcol * tmpColCandidate.length - tmpRowCandidate.length * tmpColCandidate.length)){
        ans ++;
    }

    console.log(ans);

}   

function DFS(tmpNode){
    for (let x of arr_v[tmpNode]){
        if (arr_time[x - 1][1] === 0) {
            arr_time[x - 1] = [x, time, 0];
            time ++;
            history.push(x);
            DFS(x - 1);
        } 
    }
    arr_time[tmpNode][2] = time;
    time ++;
    history.pop();
    return true;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
