#!/usr/bin/env python3



import collections

import sys

input=sys.stdin.readline



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

items=[set() for _ in range(h+1)]

count_h=[0]*(h+1)

count_w=[0]*(w+1)

for _ in range(m):

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

    items[y].add(x)

    count_h[y]+=1

    count_w[x]+=1

count_num=collections.defaultdict(int)

for x in range(1,w+1):

    count_num[count_w[x]]+=1

count_cand=list(count_num.keys())

count_cand=sorted(count_cand,reverse=True)

ans=0

for y in range(1,h+1):

    value_y=count_h[y]

    count_tmp=collections.defaultdict(int)

    for x in items[y]:

        value_x=count_w[x]

        count_tmp[value_x]+=1

        ans=max(ans,value_y+value_x-1)

    for x in count_cand:

        if count_num[x]>count_tmp[x]:

            ans=max(ans,value_y+x)

            break

print(ans)
#!/usr/bin/env python3



import collections

import sys

input=sys.stdin.readline



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

items=set()

count_h=[0]*(h+1)

count_w=[0]*(w+1)

for _ in range(m):

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

    items.add((y,x))

    count_h[y]+=1

    count_w[x]+=1

max_h=max(count_h)

max_w=max(count_w)

cand_h=[]

cand_w=[]

for y in range(1,h+1):

  if count_h[y]==max_h:

    cand_h.append(y)

for x in range(1,w+1):

  if count_w[x]==max_w:

    cand_w.append(x)

ans=max_h+max_w

for y in cand_h:

  for x in cand_w:

    if (y,x) not in items:

      print(ans)

      exit()

else:

  print((ans-1))
#!/usr/bin/env python3
import collections
import sys

input = sys.stdin.readline
h, w, m = list(map(int, input().split()))
items = [set() for _ in range(h + 1)]
count_h = [0] * (h + 1)
count_w = [0] * (w + 1)
for _ in range(m):
    y, x = list(map(int, input().split()))
    items[y].add(x)
    count_h[y] += 1
    count_w[x] += 1
count_num = collections.defaultdict(int)
for x in range(1, w + 1):
    count_num[count_w[x]] += 1
count_cand = list(count_num.keys())
count_cand = sorted(count_cand, reverse=True)
ans = 0
for y in range(1, h + 1):
    value_y = count_h[y]
    count_tmp = collections.defaultdict(int)
    for x in items[y]:
        value_x = count_w[x]
        count_tmp[value_x] += 1
        ans = max(ans, value_y + value_x - 1)
    for x in count_cand:
        if count_num[x] > count_tmp[x]:
            ans = max(ans, value_y + x)
            break
print(ans)

#!/usr/bin/env python3
import collections
import sys

input = sys.stdin.readline
h, w, m = list(map(int, input().split()))
items = set()
count_h = [0] * (h + 1)
count_w = [0] * (w + 1)
for _ in range(m):
    y, x = list(map(int, input().split()))
    items.add((y, x))
    count_h[y] += 1
    count_w[x] += 1
max_h = max(count_h)
max_w = max(count_w)
cand_h = []
cand_w = []
for y in range(1, h + 1):
    if count_h[y] == max_h:
        cand_h.append(y)
for x in range(1, w + 1):
    if count_w[x] == max_w:
        cand_w.append(x)
ans = max_h + max_w
for y in cand_h:
    for x in cand_w:
        if (y, x) not in items:
            print(ans)
            exit()
else:
    print((ans - 1))

-items = [set() for _ in range(h + 1)] +items = set() -    items[y].add(x) +    items.add((y, x)) -count_num = collections.defaultdict(int) +max_h = max(count_h) +max_w = max(count_w) +cand_h = [] +cand_w = [] +for y in range(1, h + 1): +    if count_h[y] == max_h: +        cand_h.append(y) -    count_num[count_w[x]] += 1 -count_cand = list(count_num.keys()) -count_cand = sorted(count_cand, reverse=True) -ans = 0 -for y in range(1, h + 1): -    value_y = count_h[y] -    count_tmp = collections.defaultdict(int) -    for x in items[y]: -        value_x = count_w[x] -        count_tmp[value_x] += 1 -        ans = max(ans, value_y + value_x - 1) -    for x in count_cand: -        if count_num[x] > count_tmp[x]: -            ans = max(ans, value_y + x) -            break -print(ans) +    if count_w[x] == max_w: +        cand_w.append(x) +ans = max_h + max_w +for y in cand_h: +    for x in cand_w: +        if (y, x) not in items: +            print(ans) +            exit() +else: +    print((ans - 1))