import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    H, W, M = map(int, readline().split())
    row = [0] * H
    column = [0] * W
    grid = set()

    for _ in range(M):
        h, w = map(int, readline().split())
        row[h-1] += 1
        column[w-1] += 1
        grid.add((h-1,w-1))

    max_row = max(row)
    max_column = max(column)

    idx_row = [i for i,x in enumerate(row) if x == max_row]
    idx_column = [i for i,x in enumerate(column) if x == max_column]

    ans = max_row+max_column
    flag = False

    for h in idx_row:
        for w in idx_column:
            if not (h,w) in grid:
                flag = True
                break

    if flag:
        print(ans)
    else:
        print(ans-1)


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 INF = float('inf') INF float('inf') float 'inf' MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def main():
    H, W, M = map(int, readline().split())
    row = [0] * H
    column = [0] * W
    grid = set()

    for _ in range(M):
        h, w = map(int, readline().split())
        row[h-1] += 1
        column[w-1] += 1
        grid.add((h-1,w-1))

    max_row = max(row)
    max_column = max(column)

    idx_row = [i for i,x in enumerate(row) if x == max_row]
    idx_column = [i for i,x in enumerate(column) if x == max_column]

    ans = max_row+max_column
    flag = False

    for h in idx_row:
        for w in idx_column:
            if not (h,w) in grid:
                flag = True
                break

    if flag:
        print(ans)
    else:
        print(ans-1) main H, W, M = map(int, readline().split()) H map(int, readline().split()) map int readline().split() ().split () readline split W M row = [0] * H row [0] * H [0] 0 H column = [0] * W column [0] * W [0] 0 W grid = set() grid set() set for _ in range(M):
        h, w = map(int, readline().split())
        row[h-1] += 1
        column[w-1] += 1
        grid.add((h-1,w-1))

     _ range(M) range M h, w = map(int, readline().split()) h map(int, readline().split()) map int readline().split() ().split () readline split w row[h-1] += 1 row[h-1] row h-1 h 1 1 column[w-1] += 1 column[w-1] column w-1 w 1 1 grid.add((h-1,w-1)) grid.add grid add (h-1,w-1) h-1 h 1 w-1 w 1 max_row = max(row) max_row max(row) max row max_column = max(column) max_column max(column) max column i for i,x in enumerate(row) if x == max_row for i,x in enumerate(row) if x == max_row i x enumerate(row) enumerate row x == max_row x max_row if x == max_row i idx_row = [i for i,x in enumerate(row) if x == max_row] idx_row [i for i,x in enumerate(row) if x == max_row] i for i,x in enumerate(column) if x == max_column for i,x in enumerate(column) if x == max_column i x enumerate(column) enumerate column x == max_column x max_column if x == max_column i idx_column = [i for i,x in enumerate(column) if x == max_column] idx_column [i for i,x in enumerate(column) if x == max_column] ans = max_row+max_column ans max_row+max_column max_row max_column flag = False flag False for h in idx_row:
        for w in idx_column:
            if not (h,w) in grid:
                flag = True
                break

     h idx_row for w in idx_column:
            if not (h,w) in grid:
                flag = True
                break

     w idx_column if not (h,w) in grid:
                flag = True
                break

     not (h,w) in grid (h,w) in grid (h,w) h w grid flag = True flag True break if flag:
        print(ans)
    else:
        print(ans-1) flag print(ans) print ans print(ans-1) print ans-1 ans 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF = float('inf') float('inf') INF read = sys.stdin.read sys.stdin.read read MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def main():
    H, W, M = map(int, readline().split())
    row = [0] * H
    column = [0] * W
    grid = set()

    for _ in range(M):
        h, w = map(int, readline().split())
        row[h-1] += 1
        column[w-1] += 1
        grid.add((h-1,w-1))

    max_row = max(row)
    max_column = max(column)

    idx_row = [i for i,x in enumerate(row) if x == max_row]
    idx_column = [i for i,x in enumerate(column) if x == max_column]

    ans = max_row+max_column
    flag = False

    for h in idx_row:
        for w in idx_column:
            if not (h,w) in grid:
                flag = True
                break

    if flag:
        print(ans)
    else:
        print(ans-1) def main():
    H, W, M = map(int, readline().split())
    row = [0] * H
    column = [0] * W
    grid = set()

    for _ in range(M):
        h, w = map(int, readline().split())
        row[h-1] += 1
        column[w-1] += 1
        grid.add((h-1,w-1))

    max_row = max(row)
    max_column = max(column)

    idx_row = [i for i,x in enumerate(row) if x == max_row]
    idx_column = [i for i,x in enumerate(column) if x == max_column]

    ans = max_row+max_column
    flag = False

    for h in idx_row:
        for w in idx_column:
            if not (h,w) in grid:
                flag = True
                break

    if flag:
        print(ans)
    else:
        print(ans-1) main
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    H, W, M = map(int, readline().split())
    row = [0] * H
    column = [0] * W
    grid = set()

    for _ in range(M):
        h, w = map(int, readline().split())
        row[h-1] += 1
        column[w-1] += 1
        grid.add((h-1,w-1))

    max_row = max(row)
    max_column = max(column)

    idx_row = [i for i,x in enumerate(row) if x == max_row]
    idx_column = [i for i,x in enumerate(column) if x == max_column]

    ans = max_row+max_column
    flag = False

    for h in idx_row:
        for w in idx_column:
            if not (h,w) in grid:
                flag = True
                break

    if flag:
        print(ans)
    else:
        print(ans-1)


if __name__ == '__main__':
    main()
