import sys



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

A = [list([int(x) - 1 for x in input().split()]) for i in range(M)]



cnth = [0] * H

cntw = [0] * W

st = set()



for y, x in A:

    cnth[y] += 1

    cntw[x] += 1

    st.add((y, x))



my = max(cnth)

mx = max(cntw)



Y = []

X = []



for i in range(H):

    if cnth[i] == my:

        Y.append(i)



for i in range(W):

    if cntw[i] == mx:

        X.append(i)



for y in Y:

    for x in X:

        if not (y, x) in st:

            print((my + mx))

            exit(0)



print((my + mx - 1))

def solve():

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

    N = 3 * 10 ** 5

    cnth = [0] * N

    cntw = [0] * N

    dic = dict()

    for i in range(M):

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

        cnth[h] += 1

        cntw[w] += 1

        dic[(h, w)] = 1

    mh = max(cnth)

    mw = max(cntw)

    Y = []

    X = []

    for i in range(H):

        if cnth[i] == mh:

            Y.append(i)

    for i in range(W):

        if cntw[i] == mw:

            X.append(i)

    for y in Y:

        for x in X:

            if not (y, x) in dic:

                return mh + mw

    return mh + mw - 1



print((solve()))

import sys

H, W, M = list(map(int, input().split()))
A = [list([int(x) - 1 for x in input().split()]) for i in range(M)]
cnth = [0] * H
cntw = [0] * W
st = set()
for y, x in A:
    cnth[y] += 1
    cntw[x] += 1
    st.add((y, x))
my = max(cnth)
mx = max(cntw)
Y = []
X = []
for i in range(H):
    if cnth[i] == my:
        Y.append(i)
for i in range(W):
    if cntw[i] == mx:
        X.append(i)
for y in Y:
    for x in X:
        if not (y, x) in st:
            print((my + mx))
            exit(0)
print((my + mx - 1))

def solve():
    H, W, M = list(map(int, input().split()))
    N = 3 * 10**5
    cnth = [0] * N
    cntw = [0] * N
    dic = dict()
    for i in range(M):
        h, w = [int(x) - 1 for x in input().split()]
        cnth[h] += 1
        cntw[w] += 1
        dic[(h, w)] = 1
    mh = max(cnth)
    mw = max(cntw)
    Y = []
    X = []
    for i in range(H):
        if cnth[i] == mh:
            Y.append(i)
    for i in range(W):
        if cntw[i] == mw:
            X.append(i)
    for y in Y:
        for x in X:
            if not (y, x) in dic:
                return mh + mw
    return mh + mw - 1


print((solve()))

-import sys +def solve(): +    H, W, M = list(map(int, input().split())) +    N = 3 * 10**5 +    cnth = [0] * N +    cntw = [0] * N +    dic = dict() +    for i in range(M): +        h, w = [int(x) - 1 for x in input().split()] +        cnth[h] += 1 +        cntw[w] += 1 +        dic[(h, w)] = 1 +    mh = max(cnth) +    mw = max(cntw) +    Y = [] +    X = [] +    for i in range(H): +        if cnth[i] == mh: +            Y.append(i) +    for i in range(W): +        if cntw[i] == mw: +            X.append(i) +    for y in Y: +        for x in X: +            if not (y, x) in dic: +                return mh + mw +    return mh + mw - 1 -H, W, M = list(map(int, input().split())) -A = [list([int(x) - 1 for x in input().split()]) for i in range(M)] -cnth = [0] * H -cntw = [0] * W -st = set() -for y, x in A: -    cnth[y] += 1 -    cntw[x] += 1 -    st.add((y, x)) -my = max(cnth) -mx = max(cntw) -Y = [] -X = [] -for i in range(H): -    if cnth[i] == my: -        Y.append(i) -for i in range(W): -    if cntw[i] == mx: -        X.append(i) -for y in Y: -    for x in X: -        if not (y, x) in st: -            print((my + mx)) -            exit(0) -print((my + mx - 1)) + +print((solve()))