from collections import*

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

d=defaultdict(int)

a=[0]*h

b=[0]*w

for _ in range(m):

  x,y=list(map(int,input().split()))

  x-=1

  y-=1

  a[x]+=1

  b[y]+=1

  d[(x,y)]+=1



ma=max(a)

mb=max(b)



ind_x=[i for i,j in enumerate(a) if j==ma]

ind_y=[i for i,j in enumerate(b) if j==mb]





for x in ind_x:

  for y in ind_y:

    if d[(x,y)]==0:

      print((ma+mb))

      exit()

print((ma+mb-1))

from collections import*

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

d=defaultdict(int)

a=[0]*h

b=[0]*w

for _ in range(m):

  x,y=list(map(int,input().split()))

  x-=1

  y-=1

  a[x]+=1

  b[y]+=1

  d[x*10**6+y]+=1



ma=max(a)

mb=max(b)



ind_x=[i for i,j in enumerate(a) if j==ma]

ind_y=[i for i,j in enumerate(b) if j==mb]





for x in ind_x:

  for y in ind_y:

    if d[x*10**6+y]==0:

      print((ma+mb))

      exit()

print((ma+mb-1))

from collections import *

h, w, m = list(map(int, input().split()))
d = defaultdict(int)
a = [0] * h
b = [0] * w
for _ in range(m):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    a[x] += 1
    b[y] += 1
    d[(x, y)] += 1
ma = max(a)
mb = max(b)
ind_x = [i for i, j in enumerate(a) if j == ma]
ind_y = [i for i, j in enumerate(b) if j == mb]
for x in ind_x:
    for y in ind_y:
        if d[(x, y)] == 0:
            print((ma + mb))
            exit()
print((ma + mb - 1))

from collections import *

h, w, m = list(map(int, input().split()))
d = defaultdict(int)
a = [0] * h
b = [0] * w
for _ in range(m):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    a[x] += 1
    b[y] += 1
    d[x * 10**6 + y] += 1
ma = max(a)
mb = max(b)
ind_x = [i for i, j in enumerate(a) if j == ma]
ind_y = [i for i, j in enumerate(b) if j == mb]
for x in ind_x:
    for y in ind_y:
        if d[x * 10**6 + y] == 0:
            print((ma + mb))
            exit()
print((ma + mb - 1))

-    d[(x, y)] += 1 +    d[x * 10**6 + y] += 1 -        if d[(x, y)] == 0: +        if d[x * 10**6 + y] == 0: