from collections import Counter

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

ci = Counter([])

cj = Counter([])

s = set()

for i in range(m):

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

    ci[h] += 1

    cj[w] += 1

    s.add((h,w))

mi = max(ci.values())

mj = max(cj.values())

ci = sorted(list(ci.items()),key=lambda x:x[1], reverse=True)

cj = sorted(list(cj.items()),key=lambda x:x[1], reverse=True)

xi = [ci[i][0] for i in range(len(ci)) if ci[i][1] == mi]

xj = [cj[i][0] for i in range(len(cj)) if cj[i][1] == mj]

for i in xi:

    for j in xj:

        if (i,j) not in s:

            print((mi+mj))

            quit()

print((mi+mj-1))
from collections import Counter

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

ci = Counter([])

cj = Counter([])

s = set()

for i in range(m):

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

    ci[h] += 1

    cj[w] += 1

    s.add((h,w))

mi = max(ci.values())

mj = max(cj.values())

ci = list(ci.items())

cj = list(cj.items())

xi = [ci[i][0] for i in range(len(ci)) if ci[i][1] == mi]

xj = [cj[i][0] for i in range(len(cj)) if cj[i][1] == mj]

for i in xi:

    for j in xj:

        if (i,j) not in s:

            print((mi+mj))

            quit()

print((mi+mj-1))
from collections import Counter

H, W, m = list(map(int, input().split()))
ci = Counter([])
cj = Counter([])
s = set()
for i in range(m):
    h, w = list(map(int, input().split()))
    ci[h] += 1
    cj[w] += 1
    s.add((h, w))
mi = max(ci.values())
mj = max(cj.values())
ci = sorted(list(ci.items()), key=lambda x: x[1], reverse=True)
cj = sorted(list(cj.items()), key=lambda x: x[1], reverse=True)
xi = [ci[i][0] for i in range(len(ci)) if ci[i][1] == mi]
xj = [cj[i][0] for i in range(len(cj)) if cj[i][1] == mj]
for i in xi:
    for j in xj:
        if (i, j) not in s:
            print((mi + mj))
            quit()
print((mi + mj - 1))

from collections import Counter

H, W, m = list(map(int, input().split()))
ci = Counter([])
cj = Counter([])
s = set()
for i in range(m):
    h, w = list(map(int, input().split()))
    ci[h] += 1
    cj[w] += 1
    s.add((h, w))
mi = max(ci.values())
mj = max(cj.values())
ci = list(ci.items())
cj = list(cj.items())
xi = [ci[i][0] for i in range(len(ci)) if ci[i][1] == mi]
xj = [cj[i][0] for i in range(len(cj)) if cj[i][1] == mj]
for i in xi:
    for j in xj:
        if (i, j) not in s:
            print((mi + mj))
            quit()
print((mi + mj - 1))

-ci = sorted(list(ci.items()), key=lambda x: x[1], reverse=True) -cj = sorted(list(cj.items()), key=lambda x: x[1], reverse=True) +ci = list(ci.items()) +cj = list(cj.items())