'use strict';

function Main(input) {
    //H W M
    // (hi, wi)
    const tmp = input.trim().split('\n');
    const [H, W, M] = tmp
        .shift()
        .split(' ')
        .map((v) => Number(v));
    const hw = tmp.map((v) => v.split(' ').map((v) => Number(v)));
    // console.log(H, W, M, hw);

    // Hの最大値
    let arr = Array(H + 1).fill(0);
    for (const v of hw) {
        arr[v[0]] += 1;
    }
    const hmax = arr.reduce((a, b) => Math.max(a, b));
    let harr = [];
    arr.forEach((v, i) => {
        if (v === hmax) harr.push(i);
    });

    // Hの最大値それぞれについてのWの最大値
    let wmax = 0;
    for (const value of harr) {
        const newhw = hw.filter((v) => v[0] !== value);
        let arr = Array(W + 1).fill(0);
        for (const v of newhw) {
            arr[v[1]] += 1;
        }
        const wtmp = arr.reduce((a, b) => Math.max(a, b));
        if (wtmp > wmax) {
            wmax = wtmp;
        }
    }

    console.log(hmax + wmax);

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
