#!/usr/bin/env python3



# from typing import Optional

from typing import List



# from typing import Dict

from typing import Tuple

from typing import Set



# from typing import Sequence



Cod = Tuple[int, int]





def main():

    args = input().split()

    H = int(args[0])

    W = int(args[1])

    M = int(args[2])



    codList = {}

    columnSumList: List[int] = [0] * W

    rowSumList: List[int] = [0] * H

    for i in range(M):

        h, w = [int(x) for x in input().split()]

        item = (h, w)

        codList.setdefault(h, {})

        codList[h][w] = item

        columnSumList[w - 1] += 1

        rowSumList[h - 1] += 1



    maxColumnSum = max(columnSumList)

    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]

    maxRowSum = max(rowSumList)

    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]



    result = maxColumnSum + maxRowSum

    for row in maxRowIndexList:

        for column in maxColumIndexList:

            if row + 1 in codList and column + 1 in codList[row + 1]:

                continue

            else:

                print(result)

                return



    print((result - 1))





if __name__ == "__main__":

    main()

#!/usr/bin/env python3



# from typing import Optional

from typing import List



# from typing import Dict

from typing import Tuple

from typing import Set



# from typing import Sequence



Cod = Tuple[int, int]





def main():

    args = input().split()

    H = int(args[0])

    W = int(args[1])

    M = int(args[2])



    codList = set()

    columnSumList: List[int] = [0] * W

    rowSumList: List[int] = [0] * H

    for i in range(M):

        h, w = [int(x) for x in input().split()]

        item = (h, w)

        codList.add(item)

        # codList.setdefault(h, {})

        # codList[h][w] = item

        columnSumList[w - 1] += 1

        rowSumList[h - 1] += 1



    maxColumnSum = max(columnSumList)

    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]

    maxRowSum = max(rowSumList)

    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]



    result = maxColumnSum + maxRowSum

    for row in maxRowIndexList:

        for column in maxColumIndexList:

            if (row + 1, column + 1) in codList:

                continue

            else:

                print(result)

                return



    print((result - 1))





if __name__ == "__main__":

    main()

#!/usr/bin/env python3
# from typing import Optional
from typing import List

# from typing import Dict
from typing import Tuple
from typing import Set

# from typing import Sequence
Cod = Tuple[int, int]


def main():
    args = input().split()
    H = int(args[0])
    W = int(args[1])
    M = int(args[2])
    codList = {}
    columnSumList: List[int] = [0] * W
    rowSumList: List[int] = [0] * H
    for i in range(M):
        h, w = [int(x) for x in input().split()]
        item = (h, w)
        codList.setdefault(h, {})
        codList[h][w] = item
        columnSumList[w - 1] += 1
        rowSumList[h - 1] += 1
    maxColumnSum = max(columnSumList)
    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]
    maxRowSum = max(rowSumList)
    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]
    result = maxColumnSum + maxRowSum
    for row in maxRowIndexList:
        for column in maxColumIndexList:
            if row + 1 in codList and column + 1 in codList[row + 1]:
                continue
            else:
                print(result)
                return
    print((result - 1))


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
# from typing import Optional
from typing import List

# from typing import Dict
from typing import Tuple
from typing import Set

# from typing import Sequence
Cod = Tuple[int, int]


def main():
    args = input().split()
    H = int(args[0])
    W = int(args[1])
    M = int(args[2])
    codList = set()
    columnSumList: List[int] = [0] * W
    rowSumList: List[int] = [0] * H
    for i in range(M):
        h, w = [int(x) for x in input().split()]
        item = (h, w)
        codList.add(item)
        # codList.setdefault(h, {})
        # codList[h][w] = item
        columnSumList[w - 1] += 1
        rowSumList[h - 1] += 1
    maxColumnSum = max(columnSumList)
    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]
    maxRowSum = max(rowSumList)
    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]
    result = maxColumnSum + maxRowSum
    for row in maxRowIndexList:
        for column in maxColumIndexList:
            if (row + 1, column + 1) in codList:
                continue
            else:
                print(result)
                return
    print((result - 1))


if __name__ == "__main__":
    main()

-    codList = {} +    codList = set() -        codList.setdefault(h, {}) -        codList[h][w] = item +        codList.add(item) +        # codList.setdefault(h, {}) +        # codList[h][w] = item -            if row + 1 in codList and column + 1 in codList[row + 1]: +            if (row + 1, column + 1) in codList: