from collections import Counter

def main():
    h,w,m=map(int,input().split())
    hw=set([tuple(map(int,input().split())) for _ in range(m)])
    hs=Counter([i[0] for i in hw])
    ws=Counter([i[1] for i in hw])
    hh = [hs.most_common()[0]]
    for i in hs.items():
        if i[1] == hh[0][1]:
            hh.append(i)
    ww = [ws.most_common()[0]]
    for i in ws.items():
        if i[1] == ww[0][1]:
            ww.append(i)
    
    for i in hh:
        for j in ww:
            if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
    else:
        print(hh[0][1]+ww[0][1]-1)

if __name__ == "__main__":
    main() from collections import Counter def main():
    h,w,m=map(int,input().split())
    hw=set([tuple(map(int,input().split())) for _ in range(m)])
    hs=Counter([i[0] for i in hw])
    ws=Counter([i[1] for i in hw])
    hh = [hs.most_common()[0]]
    for i in hs.items():
        if i[1] == hh[0][1]:
            hh.append(i)
    ww = [ws.most_common()[0]]
    for i in ws.items():
        if i[1] == ww[0][1]:
            ww.append(i)
    
    for i in hh:
        for j in ww:
            if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
    else:
        print(hh[0][1]+ww[0][1]-1) main h,w,m=map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w m tuple(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split hw=set([tuple(map(int,input().split())) for _ in range(m)]) hw set([tuple(map(int,input().split())) for _ in range(m)]) set [tuple(map(int,input().split())) for _ in range(m)] i[0] for i in hw for i in hw i hw for i in hw i[0] i 0 hs=Counter([i[0] for i in hw]) hs Counter([i[0] for i in hw]) Counter [i[0] for i in hw] i[1] for i in hw for i in hw i hw for i in hw i[1] i 1 ws=Counter([i[1] for i in hw]) ws Counter([i[1] for i in hw]) Counter [i[1] for i in hw] hh = [hs.most_common()[0]] hh [hs.most_common()[0]] hs.most_common()[0] hs.most_common() hs.most_common hs most_common 0 for i in hs.items():
        if i[1] == hh[0][1]:
            hh.append(i)
     i hs.items() hs.items hs items if i[1] == hh[0][1]:
            hh.append(i)
     i[1] == hh[0][1] i[1] i 1 hh[0][1] [0] hh 0 1 hh.append(i) hh.append hh append i ww = [ws.most_common()[0]] ww [ws.most_common()[0]] ws.most_common()[0] ws.most_common() ws.most_common ws most_common 0 for i in ws.items():
        if i[1] == ww[0][1]:
            ww.append(i)
    
     i ws.items() ws.items ws items if i[1] == ww[0][1]:
            ww.append(i)
    
     i[1] == ww[0][1] i[1] i 1 ww[0][1] [0] ww 0 1 ww.append(i) ww.append ww append i for i in hh:
        for j in ww:
            if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
    else:
        print(hh[0][1]+ww[0][1]-1) i hh for j in ww:
            if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
     j ww if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
     (i[0], j[0]) not in hw (i[0], j[0]) i[0] i 0 j[0] j 0 hw print(i[1] + j[1]) print i[1] + j[1] i[1] i 1 j[1] j 1 return print(hh[0][1]+ww[0][1]-1) print hh[0][1]+ww[0][1]-1 hh[0][1]+ww[0][1] hh[0][1] [0] hh 0 1 ww[0][1] [0] ww 0 1 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    h,w,m=map(int,input().split())
    hw=set([tuple(map(int,input().split())) for _ in range(m)])
    hs=Counter([i[0] for i in hw])
    ws=Counter([i[1] for i in hw])
    hh = [hs.most_common()[0]]
    for i in hs.items():
        if i[1] == hh[0][1]:
            hh.append(i)
    ww = [ws.most_common()[0]]
    for i in ws.items():
        if i[1] == ww[0][1]:
            ww.append(i)
    
    for i in hh:
        for j in ww:
            if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
    else:
        print(hh[0][1]+ww[0][1]-1) def main():
    h,w,m=map(int,input().split())
    hw=set([tuple(map(int,input().split())) for _ in range(m)])
    hs=Counter([i[0] for i in hw])
    ws=Counter([i[1] for i in hw])
    hh = [hs.most_common()[0]]
    for i in hs.items():
        if i[1] == hh[0][1]:
            hh.append(i)
    ww = [ws.most_common()[0]]
    for i in ws.items():
        if i[1] == ww[0][1]:
            ww.append(i)
    
    for i in hh:
        for j in ww:
            if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
    else:
        print(hh[0][1]+ww[0][1]-1) main
from collections import Counter

def main():
    h,w,m=map(int,input().split())
    hw=set([tuple(map(int,input().split())) for _ in range(m)])
    hs=Counter([i[0] for i in hw])
    ws=Counter([i[1] for i in hw])
    hh = [hs.most_common()[0]]
    for i in hs.items():
        if i[1] == hh[0][1]:
            hh.append(i)
    ww = [ws.most_common()[0]]
    for i in ws.items():
        if i[1] == ww[0][1]:
            ww.append(i)
    
    for i in hh:
        for j in ww:
            if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
    else:
        print(hh[0][1]+ww[0][1]-1)

if __name__ == "__main__":
    main()