import sys

H, W, M = list(map(int, sys.stdin.readline().split()))

hlst = {}

wlst = {}

hwlst = []



for i in range(M):

    h, w = sys.stdin.readline().split()

    if h in hlst:

        hlst[h] += 1

    else:

        hlst[h] = 1



    if w in wlst:

        wlst[w] += 1

    else:

        wlst[w] = 1



    hwlst.append([h, w])



h = max(hlst.values())

w = max(wlst.values())

hmax = [i for i in hlst if hlst[i] == h]

wmax = [i for i in wlst if wlst[i] == w]

num = len(hmax)*len(wmax)

ans = h + w -1





for i in hwlst:

    if hlst[i[0]] == h and wlst[i[1]] == w:

        num -= 1



if num == 0:

    print(ans)

else:

    print((ans+1))

import sys

H, W, M = list(map(int, sys.stdin.readline().split()))

hlst = {}

wlst = {}

hwlst = []



for i in range(M):

    h, w = list(map(int, sys.stdin.readline().split()))

    if h in hlst:

        hlst[h] += 1

    else:

        hlst[h] = 1



    if w in wlst:

        wlst[w] += 1

    else:

        wlst[w] = 1



    hwlst.append([h, w])



h = max(hlst.values())

w = max(wlst.values())

hmax = [i for i in hlst if hlst[i] == h]

wmax = [i for i in wlst if wlst[i] == w]

num = len(hmax)*len(wmax)





for i in hwlst:

    if hlst[i[0]] == h and wlst[i[1]] == w:

        num -= 1



if num:

    print((h+w))

else:

    print((h+w-1))

import sys

H, W, M = list(map(int, sys.stdin.readline().split()))
hlst = {}
wlst = {}
hwlst = []
for i in range(M):
    h, w = sys.stdin.readline().split()
    if h in hlst:
        hlst[h] += 1
    else:
        hlst[h] = 1
    if w in wlst:
        wlst[w] += 1
    else:
        wlst[w] = 1
    hwlst.append([h, w])
h = max(hlst.values())
w = max(wlst.values())
hmax = [i for i in hlst if hlst[i] == h]
wmax = [i for i in wlst if wlst[i] == w]
num = len(hmax) * len(wmax)
ans = h + w - 1
for i in hwlst:
    if hlst[i[0]] == h and wlst[i[1]] == w:
        num -= 1
if num == 0:
    print(ans)
else:
    print((ans + 1))

import sys

H, W, M = list(map(int, sys.stdin.readline().split()))
hlst = {}
wlst = {}
hwlst = []
for i in range(M):
    h, w = list(map(int, sys.stdin.readline().split()))
    if h in hlst:
        hlst[h] += 1
    else:
        hlst[h] = 1
    if w in wlst:
        wlst[w] += 1
    else:
        wlst[w] = 1
    hwlst.append([h, w])
h = max(hlst.values())
w = max(wlst.values())
hmax = [i for i in hlst if hlst[i] == h]
wmax = [i for i in wlst if wlst[i] == w]
num = len(hmax) * len(wmax)
for i in hwlst:
    if hlst[i[0]] == h and wlst[i[1]] == w:
        num -= 1
if num:
    print((h + w))
else:
    print((h + w - 1))

-    h, w = sys.stdin.readline().split() +    h, w = list(map(int, sys.stdin.readline().split())) -ans = h + w - 1 -if num == 0: -    print(ans) +if num: +    print((h + w)) -    print((ans + 1)) +    print((h + w - 1))