def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1)

if __name__ == '__main__':
    main()
 def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1) main import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline h,w,m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m 0 for _ in range(h) for _ in range(h) _ range(h) range h for _ in range(h) 0 h_count = [0 for _ in range(h)] h_count [0 for _ in range(h)] 0 for _ in range(w) for _ in range(w) _ range(w) range w for _ in range(w) 0 w_count = [0 for _ in range(w)] w_count [0 for _ in range(w)] pairs = set() pairs set() set for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

     i range (m) range m hi, wi = map(int, input().split()) hi map(int, input().split()) map int input().split() ().split () input split wi hi -= 1 hi 1 wi -= 1 wi 1 h_count[hi] += 1 h_count[hi] h_count hi 1 w_count[wi] += 1 w_count[wi] w_count wi 1 pairs.add((hi,wi)) pairs.add pairs add (hi,wi) hi wi h_max = max(h_count) h_max max(h_count) max h_count w_max = max(w_count) w_max max(w_count) max w_count hk = list() hk list() list wk = list() wk list() list for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
     index hj enumerate(h_count) enumerate h_count if hj == h_max:
            hk.append(index)
    
     hj == h_max hj h_max hk.append(index) hk.append hk append index for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

     index wj enumerate(w_count) enumerate w_count if wj == w_max:
            wk.append(index)

     wj == w_max wj w_max wk.append(index) wk.append wk append index ans = h_max + w_max ans h_max + w_max h_max w_max for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
     _h hk for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
     _w wk hw = (_h, _w) hw (_h, _w) _h _w if hw in pairs:
                continue

             hw in pairs hw pairs continue print(ans) print ans exit() exit print(ans -1) print ans -1 ans 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1) def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1) main
def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1)

if __name__ == '__main__':
    main()

