def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = max(hc)
    maw = max(wc)
    ans = mah+maw
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw == w:
            wmaps.add(i)

    for h in hmaps:
        for w in wmaps:
            if (h, w) not in maps:
                print(ans)
                return
    else:
        print(ans-1)


if __name__ == '__main__':
    main() def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = max(hc)
    maw = max(wc)
    ans = mah+maw
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw == w:
            wmaps.add(i)

    for h in hmaps:
        for w in wmaps:
            if (h, w) not in maps:
                print(ans)
                return
    else:
        print(ans-1) main int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i H, W, M = (int(i) for i in input().split()) H (int(i) for i in input().split()) W M hc = [0]*(H+1) hc [0]*(H+1) [0] 0 H+1 H 1 wc = [0]*(W+1) wc [0]*(W+1) [0] 0 W+1 W 1 maps = set() maps set() set for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
     _ range(M) range M int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i h, w = (int(i) for i in input().split()) h (int(i) for i in input().split()) w hc[h] += 1 hc[h] hc h 1 wc[w] += 1 wc[w] wc w 1 maps.add((h, w)) maps.add maps add (h, w) h w mah = max(hc) mah max(hc) max hc maw = max(wc) maw max(wc) max wc ans = mah+maw ans mah+maw mah maw hmaps = set() hmaps set() set wmaps = set() wmaps set() set for i, h in enumerate(hc):
        if mah == h:
            hmaps.add(i)
     i h enumerate(hc) enumerate hc if mah == h:
            hmaps.add(i)
     mah == h mah h hmaps.add(i) hmaps.add hmaps add i for i, w in enumerate(wc):
        if maw == w:
            wmaps.add(i)

     i w enumerate(wc) enumerate wc if maw == w:
            wmaps.add(i)

     maw == w maw w wmaps.add(i) wmaps.add wmaps add i for h in hmaps:
        for w in wmaps:
            if (h, w) not in maps:
                print(ans)
                return
    else:
        print(ans-1) h hmaps for w in wmaps:
            if (h, w) not in maps:
                print(ans)
                return
     w wmaps if (h, w) not in maps:
                print(ans)
                return
     (h, w) not in maps (h, w) h w maps print(ans) print ans return print(ans-1) print ans-1 ans 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = max(hc)
    maw = max(wc)
    ans = mah+maw
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw == w:
            wmaps.add(i)

    for h in hmaps:
        for w in wmaps:
            if (h, w) not in maps:
                print(ans)
                return
    else:
        print(ans-1) def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = max(hc)
    maw = max(wc)
    ans = mah+maw
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw == w:
            wmaps.add(i)

    for h in hmaps:
        for w in wmaps:
            if (h, w) not in maps:
                print(ans)
                return
    else:
        print(ans-1) main
def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = max(hc)
    maw = max(wc)
    ans = mah+maw
    hmaps = set()
    wmaps = set()
    for i, h in enumerate(hc):
        if mah == h:
            hmaps.add(i)
    for i, w in enumerate(wc):
        if maw == w:
            wmaps.add(i)

    for h in hmaps:
        for w in wmaps:
            if (h, w) not in maps:
                print(ans)
                return
    else:
        print(ans-1)


if __name__ == '__main__':
    main()
