import sys

from collections import deque





def input():

    return sys.stdin.readline().rstrip()





def main():

    H, W, M = list(map(int, input().split()))

    lh = [0] * H

    lw = [0] * W

    s = set()

    for _ in range(M):

        h, w = list(map(int, input().split()))

        lh[h - 1] += 1

        lw[w - 1] += 1

        s.add((h-1, w-1))



    maxh = max(lh)

    maxw = max(lw)

    wlist=[]

    for j in range(W):

        if maxw==lw[j]:

            wlist.append(j)







    for i in range(H):

        if lh[i] !=maxh:

            continue

        for j in wlist:

            if (i,j) not in s:

                print((maxh+maxw))

                exit()



    print((maxh+maxw-1))







if __name__ == "__main__":

    main()

import sys

from collections import deque





def input():

    return sys.stdin.readline().rstrip()





def main():

    H, W, M = list(map(int, input().split()))

    lh = [0] * H

    lw = [0] * W

    ll = []

    for _ in range(M):

        h, w = list(map(int, input().split()))

        lh[h - 1] += 1

        lw[w - 1] += 1

        ll.append((h - 1, w - 1))



    maxh = max(lh)

    maxw = max(lw)

    wlist = []





    # for i in range(H):

    #     if lh[i] != maxh:

    #         continue

    #     for j in wlist:

    #         if (i, j) not in s:

    #             print(maxh + maxw)

    #             exit()

    count = lh.count(maxh) * lw.count(maxw)

    for h, w in ll:

        if lh[h] == maxh and lw[w] == maxw:

            count -= 1



    if count:

        print((maxh + maxw))

    else:

        print((maxh + maxw - 1))





if __name__ == "__main__":

    main()

import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W, M = list(map(int, input().split()))
    lh = [0] * H
    lw = [0] * W
    s = set()
    for _ in range(M):
        h, w = list(map(int, input().split()))
        lh[h - 1] += 1
        lw[w - 1] += 1
        s.add((h - 1, w - 1))
    maxh = max(lh)
    maxw = max(lw)
    wlist = []
    for j in range(W):
        if maxw == lw[j]:
            wlist.append(j)
    for i in range(H):
        if lh[i] != maxh:
            continue
        for j in wlist:
            if (i, j) not in s:
                print((maxh + maxw))
                exit()
    print((maxh + maxw - 1))


if __name__ == "__main__":
    main()

import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W, M = list(map(int, input().split()))
    lh = [0] * H
    lw = [0] * W
    ll = []
    for _ in range(M):
        h, w = list(map(int, input().split()))
        lh[h - 1] += 1
        lw[w - 1] += 1
        ll.append((h - 1, w - 1))
    maxh = max(lh)
    maxw = max(lw)
    wlist = []
    # for i in range(H):
    #     if lh[i] != maxh:
    #         continue
    #     for j in wlist:
    #         if (i, j) not in s:
    #             print(maxh + maxw)
    #             exit()
    count = lh.count(maxh) * lw.count(maxw)
    for h, w in ll:
        if lh[h] == maxh and lw[w] == maxw:
            count -= 1
    if count:
        print((maxh + maxw))
    else:
        print((maxh + maxw - 1))


if __name__ == "__main__":
    main()

-    s = set() +    ll = [] -        s.add((h - 1, w - 1)) +        ll.append((h - 1, w - 1)) -    for j in range(W): -        if maxw == lw[j]: -            wlist.append(j) -    for i in range(H): -        if lh[i] != maxh: -            continue -        for j in wlist: -            if (i, j) not in s: -                print((maxh + maxw)) -                exit() -    print((maxh + maxw - 1)) +    # for i in range(H): +    #     if lh[i] != maxh: +    #         continue +    #     for j in wlist: +    #         if (i, j) not in s: +    #             print(maxh + maxw) +    #             exit() +    count = lh.count(maxh) * lw.count(maxw) +    for h, w in ll: +        if lh[h] == maxh and lw[w] == maxw: +            count -= 1 +    if count: +        print((maxh + maxw)) +    else: +        print((maxh + maxw - 1))