def main():
    h, w, m = map(int, input().split())
    hp = [0]*h
    wp = [0]*w
    hw = set()
    for _ in range(m):
        h1, w1 = map(int, input().split())
        hp[h1-1] += 1
        wp[w1-1] += 1
        hw.add((h1, w1))

    h_max = max(hp)
    w_max = max(wp)

    hh = [i+1 for i, v in enumerate(hp) if v == h_max]
    ww = [i+1 for i, v in enumerate(wp) if v == w_max]
    ans = h_max + w_max

    for hb in hh:
        for wb in ww:
            if (hb, wb) not in hw:
                print(ans)
                exit()
    print(ans-1)


if __name__ == '__main__':
    main() def main():
    h, w, m = map(int, input().split())
    hp = [0]*h
    wp = [0]*w
    hw = set()
    for _ in range(m):
        h1, w1 = map(int, input().split())
        hp[h1-1] += 1
        wp[w1-1] += 1
        hw.add((h1, w1))

    h_max = max(hp)
    w_max = max(wp)

    hh = [i+1 for i, v in enumerate(hp) if v == h_max]
    ww = [i+1 for i, v in enumerate(wp) if v == w_max]
    ans = h_max + w_max

    for hb in hh:
        for wb in ww:
            if (hb, wb) not in hw:
                print(ans)
                exit()
    print(ans-1) main h, w, m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m hp = [0]*h hp [0]*h [0] 0 h wp = [0]*w wp [0]*w [0] 0 w hw = set() hw set() set for _ in range(m):
        h1, w1 = map(int, input().split())
        hp[h1-1] += 1
        wp[w1-1] += 1
        hw.add((h1, w1))

     _ range(m) range m h1, w1 = map(int, input().split()) h1 map(int, input().split()) map int input().split() ().split () input split w1 hp[h1-1] += 1 hp[h1-1] hp h1-1 h1 1 1 wp[w1-1] += 1 wp[w1-1] wp w1-1 w1 1 1 hw.add((h1, w1)) hw.add hw add (h1, w1) h1 w1 h_max = max(hp) h_max max(hp) max hp w_max = max(wp) w_max max(wp) max wp i+1 for i, v in enumerate(hp) if v == h_max for i, v in enumerate(hp) if v == h_max i v enumerate(hp) enumerate hp v == h_max v h_max if v == h_max i+1 i 1 hh = [i+1 for i, v in enumerate(hp) if v == h_max] hh [i+1 for i, v in enumerate(hp) if v == h_max] i+1 for i, v in enumerate(wp) if v == w_max for i, v in enumerate(wp) if v == w_max i v enumerate(wp) enumerate wp v == w_max v w_max if v == w_max i+1 i 1 ww = [i+1 for i, v in enumerate(wp) if v == w_max] ww [i+1 for i, v in enumerate(wp) if v == w_max] ans = h_max + w_max ans h_max + w_max h_max w_max for hb in hh:
        for wb in ww:
            if (hb, wb) not in hw:
                print(ans)
                exit()
     hb hh for wb in ww:
            if (hb, wb) not in hw:
                print(ans)
                exit()
     wb ww if (hb, wb) not in hw:
                print(ans)
                exit()
     (hb, wb) not in hw (hb, wb) hb wb hw 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():
    h, w, m = map(int, input().split())
    hp = [0]*h
    wp = [0]*w
    hw = set()
    for _ in range(m):
        h1, w1 = map(int, input().split())
        hp[h1-1] += 1
        wp[w1-1] += 1
        hw.add((h1, w1))

    h_max = max(hp)
    w_max = max(wp)

    hh = [i+1 for i, v in enumerate(hp) if v == h_max]
    ww = [i+1 for i, v in enumerate(wp) if v == w_max]
    ans = h_max + w_max

    for hb in hh:
        for wb in ww:
            if (hb, wb) not in hw:
                print(ans)
                exit()
    print(ans-1) def main():
    h, w, m = map(int, input().split())
    hp = [0]*h
    wp = [0]*w
    hw = set()
    for _ in range(m):
        h1, w1 = map(int, input().split())
        hp[h1-1] += 1
        wp[w1-1] += 1
        hw.add((h1, w1))

    h_max = max(hp)
    w_max = max(wp)

    hh = [i+1 for i, v in enumerate(hp) if v == h_max]
    ww = [i+1 for i, v in enumerate(wp) if v == w_max]
    ans = h_max + w_max

    for hb in hh:
        for wb in ww:
            if (hb, wb) not in hw:
                print(ans)
                exit()
    print(ans-1) main
def main():
    h, w, m = map(int, input().split())
    hp = [0]*h
    wp = [0]*w
    hw = set()
    for _ in range(m):
        h1, w1 = map(int, input().split())
        hp[h1-1] += 1
        wp[w1-1] += 1
        hw.add((h1, w1))

    h_max = max(hp)
    w_max = max(wp)

    hh = [i+1 for i, v in enumerate(hp) if v == h_max]
    ww = [i+1 for i, v in enumerate(wp) if v == w_max]
    ans = h_max + w_max

    for hb in hh:
        for wb in ww:
            if (hb, wb) not in hw:
                print(ans)
                exit()
    print(ans-1)


if __name__ == '__main__':
    main()