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

hh=[[0,i]for i in range(h)]

ww=[[0,i]for i in range(w)]

hw=set()

for _ in range(m):

  a,b=map(int,input().split())

  a-=1

  b-=1

  hh[a][0]+=1

  ww[b][0]+=1

  hw.add((a,b))

ww.sort(reverse=1)

s=ww[0][0]

w=[]

for x,j in ww:

  if x==s:w.append(j)

hh.sort(reverse=1)

ans=0

t=max(hh)[0]

for j in w:

  for x,i in hh:

    if x!=t:break

    if (i,j) in hw:

      ans=s+x-1

    else:

      exit(print(s+x))

print(ans)

import sys

input = lambda: sys.stdin.readline().rstrip()



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



hw = []

hcount = [0] * h

wcount = [0] * w

for _ in range(m):

  a, b = list(map(int, input().split()))

  a -= 1

  b -= 1

  hcount[a] += 1

  wcount[b] += 1

  hw.append([a, b])



hmax = max(hcount)

wmax = max(wcount)



x = hcount.count(hmax) * wcount.count(wmax)

for a, b in hw:

  if hcount[a] == hmax and wcount[b] == wmax:

    x -= 1



if x == 0:

  print((hmax + wmax - 1))

else:

  print((hmax + wmax))

h, w, m = map(int, input().split())
hh = [[0, i] for i in range(h)]
ww = [[0, i] for i in range(w)]
hw = set()
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    hh[a][0] += 1
    ww[b][0] += 1
    hw.add((a, b))
ww.sort(reverse=1)
s = ww[0][0]
w = []
for x, j in ww:
    if x == s:
        w.append(j)
hh.sort(reverse=1)
ans = 0
t = max(hh)[0]
for j in w:
    for x, i in hh:
        if x != t:
            break
        if (i, j) in hw:
            ans = s + x - 1
        else:
            exit(print(s + x))
print(ans)

import sys

input = lambda: sys.stdin.readline().rstrip()
h, w, m = list(map(int, input().split()))
hw = []
hcount = [0] * h
wcount = [0] * w
for _ in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    hcount[a] += 1
    wcount[b] += 1
    hw.append([a, b])
hmax = max(hcount)
wmax = max(wcount)
x = hcount.count(hmax) * wcount.count(wmax)
for a, b in hw:
    if hcount[a] == hmax and wcount[b] == wmax:
        x -= 1
if x == 0:
    print((hmax + wmax - 1))
else:
    print((hmax + wmax))

-h, w, m = map(int, input().split()) -hh = [[0, i] for i in range(h)] -ww = [[0, i] for i in range(w)] -hw = set() +import sys + +input = lambda: sys.stdin.readline().rstrip() +h, w, m = list(map(int, input().split())) +hw = [] +hcount = [0] * h +wcount = [0] * w -    a, b = map(int, input().split()) +    a, b = list(map(int, input().split())) -    hh[a][0] += 1 -    ww[b][0] += 1 -    hw.add((a, b)) -ww.sort(reverse=1) -s = ww[0][0] -w = [] -for x, j in ww: -    if x == s: -        w.append(j) -hh.sort(reverse=1) -ans = 0 -t = max(hh)[0] -for j in w: -    for x, i in hh: -        if x != t: -            break -        if (i, j) in hw: -            ans = s + x - 1 -        else: -            exit(print(s + x)) -print(ans) +    hcount[a] += 1 +    wcount[b] += 1 +    hw.append([a, b]) +hmax = max(hcount) +wmax = max(wcount) +x = hcount.count(hmax) * wcount.count(wmax) +for a, b in hw: +    if hcount[a] == hmax and wcount[b] == wmax: +        x -= 1 +if x == 0: +    print((hmax + wmax - 1)) +else: +    print((hmax + wmax))