from sys import stdin, setrecursionlimit

#input = stdin.buffer.readline

setrecursionlimit(10 ** 7)



from heapq import heappush, heappop

from bisect import bisect_left, bisect_right

from collections import deque, defaultdict, Counter

from itertools import combinations, permutations, combinations_with_replacement

from itertools import accumulate

from math import ceil, sqrt, pi, radians, sin, cos



MOD = 10 ** 9 + 7

INF = 10 ** 6



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

hw = [list(map(int, input().split())) for _ in range(M)]



cnt = defaultdict(int)

cnt_h = defaultdict(int)

cnt_w = defaultdict(int)



for h, w in hw:

    cnt[h * INF + w] += 1

#print(cnt)



for h, w in hw:

    cnt_h[h] += 1

    cnt_w[w] += 1

cnt_h = list(cnt_h.items())

cnt_w = list(cnt_w.items())

cnt_h.sort(key = lambda x: -x[1])

cnt_w.sort(key = lambda x: -x[1])

#print(cnt_h)

#print(cnt_w)



max_h = []

max_w = []

for h, n in cnt_h:

    if n == cnt_h[0][1]:

        max_h.append(h)

for w, n in cnt_w:

    if n == cnt_w[0][1]:

        max_w.append(w)

#print(max_h)

#print(max_w)



answer = cnt_h[0][1] + cnt_w[0][1]

for mh in max_h:

    for mw in max_w:

        if cnt[mh * INF + mw] == 0:

            print(answer)

            exit()

print((answer - 1))
from sys import stdin, setrecursionlimit

input = stdin.buffer.readline



from collections import deque, defaultdict, Counter



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

hw = [list(map(int, input().split())) for _ in range(M)]



cnt = defaultdict(int)

cnt_h = defaultdict(int)

cnt_w = defaultdict(int)



for h, w in hw:

    cnt[(h, w)] += 1



for h, w in hw:

    cnt_h[h] += 1

    cnt_w[w] += 1

cnt_h = list(cnt_h.items())

cnt_w = list(cnt_w.items())

cnt_h.sort(key = lambda x: -x[1])

cnt_w.sort(key = lambda x: -x[1])



max_h = []

max_w = []

for h, n in cnt_h:

    if n == cnt_h[0][1]:

        max_h.append(h)

for w, n in cnt_w:

    if n == cnt_w[0][1]:

        max_w.append(w)



answer = cnt_h[0][1] + cnt_w[0][1]

for mh in max_h:

    for mw in max_w:

        if cnt[(mh, mw)] == 0:

            print(answer)

            exit()



print((answer - 1))
from sys import stdin, setrecursionlimit

# input = stdin.buffer.readline
setrecursionlimit(10**7)
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10**9 + 7
INF = 10**6
H, W, M = list(map(int, input().split()))
hw = [list(map(int, input().split())) for _ in range(M)]
cnt = defaultdict(int)
cnt_h = defaultdict(int)
cnt_w = defaultdict(int)
for h, w in hw:
    cnt[h * INF + w] += 1
# print(cnt)
for h, w in hw:
    cnt_h[h] += 1
    cnt_w[w] += 1
cnt_h = list(cnt_h.items())
cnt_w = list(cnt_w.items())
cnt_h.sort(key=lambda x: -x[1])
cnt_w.sort(key=lambda x: -x[1])
# print(cnt_h)
# print(cnt_w)
max_h = []
max_w = []
for h, n in cnt_h:
    if n == cnt_h[0][1]:
        max_h.append(h)
for w, n in cnt_w:
    if n == cnt_w[0][1]:
        max_w.append(w)
# print(max_h)
# print(max_w)
answer = cnt_h[0][1] + cnt_w[0][1]
for mh in max_h:
    for mw in max_w:
        if cnt[mh * INF + mw] == 0:
            print(answer)
            exit()
print((answer - 1))

from sys import stdin, setrecursionlimit

input = stdin.buffer.readline
from collections import deque, defaultdict, Counter

H, W, M = list(map(int, input().split()))
hw = [list(map(int, input().split())) for _ in range(M)]
cnt = defaultdict(int)
cnt_h = defaultdict(int)
cnt_w = defaultdict(int)
for h, w in hw:
    cnt[(h, w)] += 1
for h, w in hw:
    cnt_h[h] += 1
    cnt_w[w] += 1
cnt_h = list(cnt_h.items())
cnt_w = list(cnt_w.items())
cnt_h.sort(key=lambda x: -x[1])
cnt_w.sort(key=lambda x: -x[1])
max_h = []
max_w = []
for h, n in cnt_h:
    if n == cnt_h[0][1]:
        max_h.append(h)
for w, n in cnt_w:
    if n == cnt_w[0][1]:
        max_w.append(w)
answer = cnt_h[0][1] + cnt_w[0][1]
for mh in max_h:
    for mw in max_w:
        if cnt[(mh, mw)] == 0:
            print(answer)
            exit()
print((answer - 1))

-# input = stdin.buffer.readline -setrecursionlimit(10**7) -from heapq import heappush, heappop -from bisect import bisect_left, bisect_right +input = stdin.buffer.readline -from itertools import combinations, permutations, combinations_with_replacement -from itertools import accumulate -from math import ceil, sqrt, pi, radians, sin, cos -MOD = 10**9 + 7 -INF = 10**6 -    cnt[h * INF + w] += 1 -# print(cnt) +    cnt[(h, w)] += 1 -# print(cnt_h) -# print(cnt_w) -# print(max_h) -# print(max_w) -        if cnt[mh * INF + mw] == 0: +        if cnt[(mh, mw)] == 0: