import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
def main():
    h, w, m = map(int, input().split())
    b_row = [0] * h
    b_col = [0] * w
    b_coor = set()
    m = map(int, read().split())
    for a, b in zip(m, m):
        a -= 1
        b -= 1
        b_row[a] += 1
        b_col[b] += 1
        b_coor.add((a, b))

    row_max = max(b_row)
    col_max = max(b_col)
    rows = [i for i, v in enumerate(b_row) if v == row_max]
    cols = [i for i, v in enumerate(b_col) if v == col_max]

    for r in rows:
        for c in cols:
            if (r, c) not in b_coor:
                print(row_max + col_max)
                sys.exit()
    print(row_max + col_max - 1)

if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read def main():
    h, w, m = map(int, input().split())
    b_row = [0] * h
    b_col = [0] * w
    b_coor = set()
    m = map(int, read().split())
    for a, b in zip(m, m):
        a -= 1
        b -= 1
        b_row[a] += 1
        b_col[b] += 1
        b_coor.add((a, b))

    row_max = max(b_row)
    col_max = max(b_col)
    rows = [i for i, v in enumerate(b_row) if v == row_max]
    cols = [i for i, v in enumerate(b_col) if v == col_max]

    for r in rows:
        for c in cols:
            if (r, c) not in b_coor:
                print(row_max + col_max)
                sys.exit()
    print(row_max + col_max - 1) main h, w, m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m b_row = [0] * h b_row [0] * h [0] 0 h b_col = [0] * w b_col [0] * w [0] 0 w b_coor = set() b_coor set() set m = map(int, read().split()) m map(int, read().split()) map int read().split() ().split () read split for a, b in zip(m, m):
        a -= 1
        b -= 1
        b_row[a] += 1
        b_col[b] += 1
        b_coor.add((a, b))

     a b zip(m, m) zip m m a -= 1 a 1 b -= 1 b 1 b_row[a] += 1 b_row[a] b_row a 1 b_col[b] += 1 b_col[b] b_col b 1 b_coor.add((a, b)) b_coor.add b_coor add (a, b) a b row_max = max(b_row) row_max max(b_row) max b_row col_max = max(b_col) col_max max(b_col) max b_col i for i, v in enumerate(b_row) if v == row_max for i, v in enumerate(b_row) if v == row_max i v enumerate(b_row) enumerate b_row v == row_max v row_max if v == row_max i rows = [i for i, v in enumerate(b_row) if v == row_max] rows [i for i, v in enumerate(b_row) if v == row_max] i for i, v in enumerate(b_col) if v == col_max for i, v in enumerate(b_col) if v == col_max i v enumerate(b_col) enumerate b_col v == col_max v col_max if v == col_max i cols = [i for i, v in enumerate(b_col) if v == col_max] cols [i for i, v in enumerate(b_col) if v == col_max] for r in rows:
        for c in cols:
            if (r, c) not in b_coor:
                print(row_max + col_max)
                sys.exit()
     r rows for c in cols:
            if (r, c) not in b_coor:
                print(row_max + col_max)
                sys.exit()
     c cols if (r, c) not in b_coor:
                print(row_max + col_max)
                sys.exit()
     (r, c) not in b_coor (r, c) r c b_coor print(row_max + col_max) print row_max + col_max row_max col_max sys.exit() sys.exit sys exit print(row_max + col_max - 1) print row_max + col_max - 1 row_max + col_max row_max col_max 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main read = sys.stdin.read sys.stdin.read read def main():
    h, w, m = map(int, input().split())
    b_row = [0] * h
    b_col = [0] * w
    b_coor = set()
    m = map(int, read().split())
    for a, b in zip(m, m):
        a -= 1
        b -= 1
        b_row[a] += 1
        b_col[b] += 1
        b_coor.add((a, b))

    row_max = max(b_row)
    col_max = max(b_col)
    rows = [i for i, v in enumerate(b_row) if v == row_max]
    cols = [i for i, v in enumerate(b_col) if v == col_max]

    for r in rows:
        for c in cols:
            if (r, c) not in b_coor:
                print(row_max + col_max)
                sys.exit()
    print(row_max + col_max - 1) def main():
    h, w, m = map(int, input().split())
    b_row = [0] * h
    b_col = [0] * w
    b_coor = set()
    m = map(int, read().split())
    for a, b in zip(m, m):
        a -= 1
        b -= 1
        b_row[a] += 1
        b_col[b] += 1
        b_coor.add((a, b))

    row_max = max(b_row)
    col_max = max(b_col)
    rows = [i for i, v in enumerate(b_row) if v == row_max]
    cols = [i for i, v in enumerate(b_col) if v == col_max]

    for r in rows:
        for c in cols:
            if (r, c) not in b_coor:
                print(row_max + col_max)
                sys.exit()
    print(row_max + col_max - 1) main
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
def main():
    h, w, m = map(int, input().split())
    b_row = [0] * h
    b_col = [0] * w
    b_coor = set()
    m = map(int, read().split())
    for a, b in zip(m, m):
        a -= 1
        b -= 1
        b_row[a] += 1
        b_col[b] += 1
        b_coor.add((a, b))

    row_max = max(b_row)
    col_max = max(b_col)
    rows = [i for i, v in enumerate(b_row) if v == row_max]
    cols = [i for i, v in enumerate(b_col) if v == col_max]

    for r in rows:
        for c in cols:
            if (r, c) not in b_coor:
                print(row_max + col_max)
                sys.exit()
    print(row_max + col_max - 1)

if __name__ == '__main__':
    main()
