import sys

input = sys.stdin.buffer.readline



def main():



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

    #HW = [0]*m



    HC = [0]*H

    WC = [0]*W



    A = [0]*M



    for i in range(M):

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

        h, w = h-1, w-1

        #HW[i] = (h, w)

        HC[h] += 1

        WC[w] += 1

        A[i] = (h, w)



    from collections import Counter

    hct = Counter(HC)

    wct = Counter(WC)

    hct = list(hct.items())

    wct = list(wct.items())

    hct.sort(reverse=True)

    wct.sort(reverse=True)

    #print(hct)

    #print(wct)

    temph = hct[0][0]

    tempw= wct[0][0]

    tempa = temph+tempw

    cnthw = hct[0][1]*wct[0][1]

    cnt = 0

    for h, w in A:

        if HC[h]+WC[w] ==tempa:

            cnt += 1

    #print(cnt, cnthw)

    if cnt < cnthw:

        print(tempa)

    else:

        print((tempa-1))



if __name__ == '__main__':

    main()

import sys

import io, os

#input = sys.stdin.buffer.readline

input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline



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

R = [0]*h

C = [0]*w

YX = []

for i in range(m):

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

    y, x = y-1, x-1

    R[y] +=1

    C[x] +=1

    YX.append((y, x))



max_r = max(R)

max_c = max(C)

cr = 0

cc = 0

for i in range(h):

    if R[i] == max_r:

        cr += 1

for i in range(w):

    if C[i] == max_c:

        cc +=1

c = 0

for y, x in YX:

    if R[y] == max_r and C[x] == max_c:

        c += 1

if c < cr*cc:

    print((max_r+max_c))

else:

    print((max_r+max_c-1))

import sys

input = sys.stdin.buffer.readline


def main():
    H, W, M = list(map(int, input().split()))
    # HW = [0]*m
    HC = [0] * H
    WC = [0] * W
    A = [0] * M
    for i in range(M):
        h, w = list(map(int, input().split()))
        h, w = h - 1, w - 1
        # HW[i] = (h, w)
        HC[h] += 1
        WC[w] += 1
        A[i] = (h, w)
    from collections import Counter

    hct = Counter(HC)
    wct = Counter(WC)
    hct = list(hct.items())
    wct = list(wct.items())
    hct.sort(reverse=True)
    wct.sort(reverse=True)
    # print(hct)
    # print(wct)
    temph = hct[0][0]
    tempw = wct[0][0]
    tempa = temph + tempw
    cnthw = hct[0][1] * wct[0][1]
    cnt = 0
    for h, w in A:
        if HC[h] + WC[w] == tempa:
            cnt += 1
    # print(cnt, cnthw)
    if cnt < cnthw:
        print(tempa)
    else:
        print((tempa - 1))


if __name__ == "__main__":
    main()

import sys
import io, os

# input = sys.stdin.buffer.readline
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
h, w, m = list(map(int, input().split()))
R = [0] * h
C = [0] * w
YX = []
for i in range(m):
    y, x = list(map(int, input().split()))
    y, x = y - 1, x - 1
    R[y] += 1
    C[x] += 1
    YX.append((y, x))
max_r = max(R)
max_c = max(C)
cr = 0
cc = 0
for i in range(h):
    if R[i] == max_r:
        cr += 1
for i in range(w):
    if C[i] == max_c:
        cc += 1
c = 0
for y, x in YX:
    if R[y] == max_r and C[x] == max_c:
        c += 1
if c < cr * cc:
    print((max_r + max_c))
else:
    print((max_r + max_c - 1))

+import io, os -input = sys.stdin.buffer.readline - - -def main(): -    H, W, M = list(map(int, input().split())) -    # HW = [0]*m -    HC = [0] * H -    WC = [0] * W -    A = [0] * M -    for i in range(M): -        h, w = list(map(int, input().split())) -        h, w = h - 1, w - 1 -        # HW[i] = (h, w) -        HC[h] += 1 -        WC[w] += 1 -        A[i] = (h, w) -    from collections import Counter - -    hct = Counter(HC) -    wct = Counter(WC) -    hct = list(hct.items()) -    wct = list(wct.items()) -    hct.sort(reverse=True) -    wct.sort(reverse=True) -    # print(hct) -    # print(wct) -    temph = hct[0][0] -    tempw = wct[0][0] -    tempa = temph + tempw -    cnthw = hct[0][1] * wct[0][1] -    cnt = 0 -    for h, w in A: -        if HC[h] + WC[w] == tempa: -            cnt += 1 -    # print(cnt, cnthw) -    if cnt < cnthw: -        print(tempa) -    else: -        print((tempa - 1)) - - -if __name__ == "__main__": -    main() +# input = sys.stdin.buffer.readline +input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline +h, w, m = list(map(int, input().split())) +R = [0] * h +C = [0] * w +YX = [] +for i in range(m): +    y, x = list(map(int, input().split())) +    y, x = y - 1, x - 1 +    R[y] += 1 +    C[x] += 1 +    YX.append((y, x)) +max_r = max(R) +max_c = max(C) +cr = 0 +cc = 0 +for i in range(h): +    if R[i] == max_r: +        cr += 1 +for i in range(w): +    if C[i] == max_c: +        cc += 1 +c = 0 +for y, x in YX: +    if R[y] == max_r and C[x] == max_c: +        c += 1 +if c < cr * cc: +    print((max_r + max_c)) +else: +    print((max_r + max_c - 1))