import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h,w,m] <- getIntList
    hw <- replicateM m $ do
        [x,y] <- getIntList
        return (x-1,y-1)
    
    hvec' <- VUM.replicate h (0 :: Int)
    wvec' <- VUM.replicate w (0 :: Int)
    forM_ hw $ \(x,y) -> do
        VUM.modify hvec' succ x
        VUM.modify wvec' succ y 
    hvec <- VU.freeze hvec'
    wvec <- VU.freeze wvec'

    let hmax = VU.maximum hvec
    let wmax = VU.maximum wvec
    let dhw = sum $ map check hw
          where check (x,y) | hvec VU.! x == hmax && wvec VU.! y == wmax = 1
                            | otherwise = 0
    let hidx = VU.length $ VU.filter (== hmax) hvec
    let widx = VU.length $ VU.filter (== wmax) wvec
    let lhw = hidx * widx
    let d = if dhw == lhw then 1 else 0

    print $ hmax + wmax - d