import sys



sys.setrecursionlimit(10**7)

def I(): return int(sys.stdin.readline().rstrip())

def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし

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

def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり

def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし



H,W,M = MI()

hw = [tuple(MI()) for _ in range(M)]

A = [0]*(H+1)

B = [0]*(W+1)



from collections import defaultdict

d = defaultdict(int)

for h,w in hw:

    A[h] += 1

    B[w] += 1

    d[(h,w)] = 1





ma = max(A)

mb = max(B)

ans = ma+mb

C,D = [],[]

for i in range(1,H+1):

    if A[i] == ma:

        C.append(i)

for i in range(1,W+1):

    if B[i] == mb:

        D.append(i)



if len(C)*len(D) > M:

    print(ans)

else:

    for i in C:

        for j in D:

            if d[(i,j)] == 0:

                print(ans)

                exit()

    print((ans-1))

import sys

def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))



H,W,M = MI()



X = [0]*(H+1)  # X[i] = x座標がiである爆破対象はいくつあるか

Y = [0]*(W+1)  # Y[i] = y座標がiである爆破対象はいくつあるか



from collections import defaultdict

d = defaultdict(int)  # d[(h,w)] == 1 ⇔ 座標(h,w)に爆破対象が存在する



for i in range(M):

    h,w = MI()

    X[h] += 1

    Y[w] += 1

    d[(h,w)] = 1



mx = max(X)

my = max(Y)

ans = mx+my

A = [i for i in range(1,H+1) if X[i] == mx]

B = [i for i in range(1,W+1) if Y[i] == my]



if len(A)*len(B) > M:

    print(ans)

else:

    for i in A:

        for j in B:

            if d[(i,j)] == 0:

                print(ans)

                exit()

    print((ans-1))

import sys

sys.setrecursionlimit(10**7)


def I():
    return int(sys.stdin.readline().rstrip())


def MI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり


def LI2():
    return list(map(int, sys.stdin.readline().rstrip()))  # 空白なし


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


def LS():
    return list(sys.stdin.readline().rstrip().split())  # 空白あり


def LS2():
    return list(sys.stdin.readline().rstrip())  # 空白なし


H, W, M = MI()
hw = [tuple(MI()) for _ in range(M)]
A = [0] * (H + 1)
B = [0] * (W + 1)
from collections import defaultdict

d = defaultdict(int)
for h, w in hw:
    A[h] += 1
    B[w] += 1
    d[(h, w)] = 1
ma = max(A)
mb = max(B)
ans = ma + mb
C, D = [], []
for i in range(1, H + 1):
    if A[i] == ma:
        C.append(i)
for i in range(1, W + 1):
    if B[i] == mb:
        D.append(i)
if len(C) * len(D) > M:
    print(ans)
else:
    for i in C:
        for j in D:
            if d[(i, j)] == 0:
                print(ans)
                exit()
    print((ans - 1))

import sys


def MI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


H, W, M = MI()
X = [0] * (H + 1)  # X[i] = x座標がiである爆破対象はいくつあるか
Y = [0] * (W + 1)  # Y[i] = y座標がiである爆破対象はいくつあるか
from collections import defaultdict

d = defaultdict(int)  # d[(h,w)] == 1 ⇔ 座標(h,w)に爆破対象が存在する
for i in range(M):
    h, w = MI()
    X[h] += 1
    Y[w] += 1
    d[(h, w)] = 1
mx = max(X)
my = max(Y)
ans = mx + my
A = [i for i in range(1, H + 1) if X[i] == mx]
B = [i for i in range(1, W + 1) if Y[i] == my]
if len(A) * len(B) > M:
    print(ans)
else:
    for i in A:
        for j in B:
            if d[(i, j)] == 0:
                print(ans)
                exit()
    print((ans - 1))

- -sys.setrecursionlimit(10**7) - - -def I(): -    return int(sys.stdin.readline().rstrip()) -def LI(): -    return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり - - -def LI2(): -    return list(map(int, sys.stdin.readline().rstrip()))  # 空白なし - - -def S(): -    return sys.stdin.readline().rstrip() - - -def LS(): -    return list(sys.stdin.readline().rstrip().split())  # 空白あり - - -def LS2(): -    return list(sys.stdin.readline().rstrip())  # 空白なし - - -hw = [tuple(MI()) for _ in range(M)] -A = [0] * (H + 1) -B = [0] * (W + 1) +X = [0] * (H + 1)  # X[i] = x座標がiである爆破対象はいくつあるか +Y = [0] * (W + 1)  # Y[i] = y座標がiである爆破対象はいくつあるか -d = defaultdict(int) -for h, w in hw: -    A[h] += 1 -    B[w] += 1 +d = defaultdict(int)  # d[(h,w)] == 1 ⇔ 座標(h,w)に爆破対象が存在する +for i in range(M): +    h, w = MI() +    X[h] += 1 +    Y[w] += 1 -ma = max(A) -mb = max(B) -ans = ma + mb -C, D = [], [] -for i in range(1, H + 1): -    if A[i] == ma: -        C.append(i) -for i in range(1, W + 1): -    if B[i] == mb: -        D.append(i) -if len(C) * len(D) > M: +mx = max(X) +my = max(Y) +ans = mx + my +A = [i for i in range(1, H + 1) if X[i] == mx] +B = [i for i in range(1, W + 1) if Y[i] == my] +if len(A) * len(B) > M: -    for i in C: -        for j in D: +    for i in A: +        for j in B: