from collections import Counter



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

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



hlst=[x for x,_ in hw]

wlst=[x for _,x in hw]



hcnt=Counter(hlst)

wcnt=Counter(wlst)





_,hmax=hcnt.most_common(1)[0]

_,wmax=wcnt.most_common(1)[0]

hcand=set([k for k,v in list(hcnt.items()) if v==hmax])

wcand=set([k for k,v in list(wcnt.items()) if v==wmax])



ng=[]



for hh,ww in hw:

    if hh in hcand and ww in wcand:

        ng.append((hh,ww))



if len(hcand)*len(wcand)>len(ng):

    print((hmax+wmax))

else:

    print((hmax+wmax-1))
from collections import Counter



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

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



hlst=[x for x,_ in hw]

wlst=[x for _,x in hw]



hcnt=Counter(hlst)

wcnt=Counter(wlst)



_,hmax=hcnt.most_common(1)[0]

_,wmax=wcnt.most_common(1)[0]

hcand=set([k for k,v in list(hcnt.items()) if v==hmax])

wcand=set([k for k,v in list(wcnt.items()) if v==wmax])



ng=[(hh,ww) for hh,ww in hw if ((hh in hcand) and (ww in wcand))]



if len(hcand)*len(wcand)>len(ng):

    print((hmax+wmax))

else:

    print((hmax+wmax-1))
from collections import Counter

h, w, m = list(map(int, input().split()))
hw = [list(map(int, input().split())) for _ in range(m)]
hlst = [x for x, _ in hw]
wlst = [x for _, x in hw]
hcnt = Counter(hlst)
wcnt = Counter(wlst)
_, hmax = hcnt.most_common(1)[0]
_, wmax = wcnt.most_common(1)[0]
hcand = set([k for k, v in list(hcnt.items()) if v == hmax])
wcand = set([k for k, v in list(wcnt.items()) if v == wmax])
ng = []
for hh, ww in hw:
    if hh in hcand and ww in wcand:
        ng.append((hh, ww))
if len(hcand) * len(wcand) > len(ng):
    print((hmax + wmax))
else:
    print((hmax + wmax - 1))

from collections import Counter

h, w, m = list(map(int, input().split()))
hw = [list(map(int, input().split())) for _ in range(m)]
hlst = [x for x, _ in hw]
wlst = [x for _, x in hw]
hcnt = Counter(hlst)
wcnt = Counter(wlst)
_, hmax = hcnt.most_common(1)[0]
_, wmax = wcnt.most_common(1)[0]
hcand = set([k for k, v in list(hcnt.items()) if v == hmax])
wcand = set([k for k, v in list(wcnt.items()) if v == wmax])
ng = [(hh, ww) for hh, ww in hw if ((hh in hcand) and (ww in wcand))]
if len(hcand) * len(wcand) > len(ng):
    print((hmax + wmax))
else:
    print((hmax + wmax - 1))

-ng = [] -for hh, ww in hw: -    if hh in hcand and ww in wcand: -        ng.append((hh, ww)) +ng = [(hh, ww) for hh, ww in hw if ((hh in hcand) and (ww in wcand))]