import sys

input = sys.stdin.readline

def main():
    ans = 0
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0]*(H)
    ws = [0]*(W)
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    maxhindex = [i for i, x in enumerate(hs) if x == maxh]
    maxwindex = [i for i, x in enumerate(ws) if x == maxw]

    isfound = False

    bombs = set(bombs)
    for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()

    print(ans-1)

if __name__ == '__main__':
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    ans = 0
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0]*(H)
    ws = [0]*(W)
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    maxhindex = [i for i, x in enumerate(hs) if x == maxh]
    maxwindex = [i for i, x in enumerate(ws) if x == maxw]

    isfound = False

    bombs = set(bombs)
    for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()

    print(ans-1) main ans = 0 ans 0 H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M bombs = [] bombs [] hs = [0]*(H) hs [0]*(H) [0] 0 H ws = [0]*(W) ws [0]*(W) [0] 0 W for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
     _ range(M) range M h, w = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w bombs.append(tuple([h-1, w-1])) bombs.append bombs append tuple([h-1, w-1]) tuple [h-1, w-1] h-1 h 1 w-1 w 1 hs[h-1] += 1 hs[h-1] hs h-1 h 1 1 ws[w-1] += 1 ws[w-1] ws w-1 w 1 1 maxh = max(hs) maxh max(hs) max hs maxw = max(ws) maxw max(ws) max ws ans = maxh + maxw ans maxh + maxw maxh maxw i for i, x in enumerate(hs) if x == maxh for i, x in enumerate(hs) if x == maxh i x enumerate(hs) enumerate hs x == maxh x maxh if x == maxh i maxhindex = [i for i, x in enumerate(hs) if x == maxh] maxhindex [i for i, x in enumerate(hs) if x == maxh] i for i, x in enumerate(ws) if x == maxw for i, x in enumerate(ws) if x == maxw i x enumerate(ws) enumerate ws x == maxw x maxw if x == maxw i maxwindex = [i for i, x in enumerate(ws) if x == maxw] maxwindex [i for i, x in enumerate(ws) if x == maxw] isfound = False isfound False bombs = set(bombs) bombs set(bombs) set bombs for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()

     i maxhindex for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()

     j maxwindex if (i, j) not in bombs:
                print(ans)
                exit()

     (i, j) not in bombs (i, j) i j bombs print(ans) print ans exit() exit print(ans-1) print ans-1 ans 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main input = sys.stdin.readline sys.stdin.readline input def main():
    ans = 0
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0]*(H)
    ws = [0]*(W)
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    maxhindex = [i for i, x in enumerate(hs) if x == maxh]
    maxwindex = [i for i, x in enumerate(ws) if x == maxw]

    isfound = False

    bombs = set(bombs)
    for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()

    print(ans-1) def main():
    ans = 0
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0]*(H)
    ws = [0]*(W)
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    maxhindex = [i for i, x in enumerate(hs) if x == maxh]
    maxwindex = [i for i, x in enumerate(ws) if x == maxw]

    isfound = False

    bombs = set(bombs)
    for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()

    print(ans-1) main
import sys

input = sys.stdin.readline

def main():
    ans = 0
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0]*(H)
    ws = [0]*(W)
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    maxhindex = [i for i, x in enumerate(hs) if x == maxh]
    maxwindex = [i for i, x in enumerate(ws) if x == maxw]

    isfound = False

    bombs = set(bombs)
    for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()

    print(ans-1)

if __name__ == '__main__':
    main()