def main():
    h,w,m=map(int,input().split())
    target=set()
    for i in range(m):
        th,tw=map(int,input().split())
        target.add((th-1,tw-1))
    lines=[0]*w
    rows=[0]*h
    for th,tw in target:
        lines[tw]+=1
        rows[th]+=1
    max_lines=max(lines)
    max_rows=max(rows)
    max_wi=[i for i,wi in enumerate(lines) if wi==max_lines]
    max_hi=[i for i,hi in enumerate(rows) if hi==max_rows]
    # print('rows\t',max_rows,max_hi,'\nlines\t',max_lines,max_wi)
    ans=max_lines+max_rows-1
    isLoop=True
    for wi in max_wi:
        if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
    return ans

if __name__=='__main__':
    ans=main()
    print(ans) def main():
    h,w,m=map(int,input().split())
    target=set()
    for i in range(m):
        th,tw=map(int,input().split())
        target.add((th-1,tw-1))
    lines=[0]*w
    rows=[0]*h
    for th,tw in target:
        lines[tw]+=1
        rows[th]+=1
    max_lines=max(lines)
    max_rows=max(rows)
    max_wi=[i for i,wi in enumerate(lines) if wi==max_lines]
    max_hi=[i for i,hi in enumerate(rows) if hi==max_rows]
    # print('rows\t',max_rows,max_hi,'\nlines\t',max_lines,max_wi)
    ans=max_lines+max_rows-1
    isLoop=True
    for wi in max_wi:
        if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
    return ans main h,w,m=map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w m target=set() target set() set for i in range(m):
        th,tw=map(int,input().split())
        target.add((th-1,tw-1))
     i range(m) range m th,tw=map(int,input().split()) th map(int,input().split()) map int input().split() ().split () input split tw target.add((th-1,tw-1)) target.add target add (th-1,tw-1) th-1 th 1 tw-1 tw 1 lines=[0]*w lines [0]*w [0] 0 w rows=[0]*h rows [0]*h [0] 0 h for th,tw in target:
        lines[tw]+=1
        rows[th]+=1
     th tw target lines[tw]+=1 lines[tw] lines tw 1 rows[th]+=1 rows[th] rows th 1 max_lines=max(lines) max_lines max(lines) max lines max_rows=max(rows) max_rows max(rows) max rows i for i,wi in enumerate(lines) if wi==max_lines for i,wi in enumerate(lines) if wi==max_lines i wi enumerate(lines) enumerate lines wi==max_lines wi max_lines if wi==max_lines i max_wi=[i for i,wi in enumerate(lines) if wi==max_lines] max_wi [i for i,wi in enumerate(lines) if wi==max_lines] i for i,hi in enumerate(rows) if hi==max_rows for i,hi in enumerate(rows) if hi==max_rows i hi enumerate(rows) enumerate rows hi==max_rows hi max_rows if hi==max_rows i max_hi=[i for i,hi in enumerate(rows) if hi==max_rows] max_hi [i for i,hi in enumerate(rows) if hi==max_rows] ans=max_lines+max_rows-1 ans max_lines+max_rows-1 max_lines+max_rows max_lines max_rows 1 isLoop=True isLoop True for wi in max_wi:
        if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
     wi max_wi if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
     isLoop for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
     hi max_hi if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
     not (hi,wi) in target (hi,wi) in target (hi,wi) hi wi target ans+=1 ans 1 isLoop=False isLoop False break return ans ans if __name__=='__main__':
    ans=main()
    print(ans) __name__=='__main__' __name__ '__main__' ans=main() ans main() main print(ans) print ans ans=main() main() ans def main():
    h,w,m=map(int,input().split())
    target=set()
    for i in range(m):
        th,tw=map(int,input().split())
        target.add((th-1,tw-1))
    lines=[0]*w
    rows=[0]*h
    for th,tw in target:
        lines[tw]+=1
        rows[th]+=1
    max_lines=max(lines)
    max_rows=max(rows)
    max_wi=[i for i,wi in enumerate(lines) if wi==max_lines]
    max_hi=[i for i,hi in enumerate(rows) if hi==max_rows]
    # print('rows\t',max_rows,max_hi,'\nlines\t',max_lines,max_wi)
    ans=max_lines+max_rows-1
    isLoop=True
    for wi in max_wi:
        if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
    return ans def main():
    h,w,m=map(int,input().split())
    target=set()
    for i in range(m):
        th,tw=map(int,input().split())
        target.add((th-1,tw-1))
    lines=[0]*w
    rows=[0]*h
    for th,tw in target:
        lines[tw]+=1
        rows[th]+=1
    max_lines=max(lines)
    max_rows=max(rows)
    max_wi=[i for i,wi in enumerate(lines) if wi==max_lines]
    max_hi=[i for i,hi in enumerate(rows) if hi==max_rows]
    # print('rows\t',max_rows,max_hi,'\nlines\t',max_lines,max_wi)
    ans=max_lines+max_rows-1
    isLoop=True
    for wi in max_wi:
        if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
    return ans main
def main():
    h,w,m=map(int,input().split())
    target=set()
    for i in range(m):
        th,tw=map(int,input().split())
        target.add((th-1,tw-1))
    lines=[0]*w
    rows=[0]*h
    for th,tw in target:
        lines[tw]+=1
        rows[th]+=1
    max_lines=max(lines)
    max_rows=max(rows)
    max_wi=[i for i,wi in enumerate(lines) if wi==max_lines]
    max_hi=[i for i,hi in enumerate(rows) if hi==max_rows]
    # print('rows\t',max_rows,max_hi,'\nlines\t',max_lines,max_wi)
    ans=max_lines+max_rows-1
    isLoop=True
    for wi in max_wi:
        if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
    return ans

if __name__=='__main__':
    ans=main()
    print(ans)
