from collections import defaultdict


def main():
    _, _, m = map(int, input().split())

    row_dict = defaultdict(int)
    col_dict = defaultdict(int)
    row_col_dict = defaultdict(set)
    for _ in range(m):
        row, col = map(int, input().split())
        row_dict[row] += 1
        col_dict[col] += 1
        row_col_dict[row].add(col)

    max_row_val = max(row_dict.values())
    max_col_val = max(col_dict.values())

    max_rows = {k for k, v in row_dict.items() if v == max_row_val}
    max_cols = {k for k, v in col_dict.items() if v == max_col_val}
    ans = max_row_val + max_col_val - 1
    flg = False
    if ans < m:
        for row in max_rows:
            for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
            if flg:
                break

    print(ans)


if __name__ == '__main__':
    main() from collections import defaultdict def main():
    _, _, m = map(int, input().split())

    row_dict = defaultdict(int)
    col_dict = defaultdict(int)
    row_col_dict = defaultdict(set)
    for _ in range(m):
        row, col = map(int, input().split())
        row_dict[row] += 1
        col_dict[col] += 1
        row_col_dict[row].add(col)

    max_row_val = max(row_dict.values())
    max_col_val = max(col_dict.values())

    max_rows = {k for k, v in row_dict.items() if v == max_row_val}
    max_cols = {k for k, v in col_dict.items() if v == max_col_val}
    ans = max_row_val + max_col_val - 1
    flg = False
    if ans < m:
        for row in max_rows:
            for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
            if flg:
                break

    print(ans) main _, _, m = map(int, input().split()) _ map(int, input().split()) map int input().split() ().split () input split _ m row_dict = defaultdict(int) row_dict defaultdict(int) defaultdict int col_dict = defaultdict(int) col_dict defaultdict(int) defaultdict int row_col_dict = defaultdict(set) row_col_dict defaultdict(set) defaultdict set for _ in range(m):
        row, col = map(int, input().split())
        row_dict[row] += 1
        col_dict[col] += 1
        row_col_dict[row].add(col)

     _ range(m) range m row, col = map(int, input().split()) row map(int, input().split()) map int input().split() ().split () input split col row_dict[row] += 1 row_dict[row] row_dict row 1 col_dict[col] += 1 col_dict[col] col_dict col 1 row_col_dict[row].add(col) [row].add [row] row_col_dict row add col max_row_val = max(row_dict.values()) max_row_val max(row_dict.values()) max row_dict.values() row_dict.values row_dict values max_col_val = max(col_dict.values()) max_col_val max(col_dict.values()) max col_dict.values() col_dict.values col_dict values k for k, v in row_dict.items() if v == max_row_val for k, v in row_dict.items() if v == max_row_val k v row_dict.items() row_dict.items row_dict items v == max_row_val v max_row_val if v == max_row_val k max_rows = {k for k, v in row_dict.items() if v == max_row_val} max_rows k for k, v in col_dict.items() if v == max_col_val for k, v in col_dict.items() if v == max_col_val k v col_dict.items() col_dict.items col_dict items v == max_col_val v max_col_val if v == max_col_val k max_cols = {k for k, v in col_dict.items() if v == max_col_val} max_cols ans = max_row_val + max_col_val - 1 ans max_row_val + max_col_val - 1 max_row_val + max_col_val max_row_val max_col_val 1 flg = False flg False if ans < m:
        for row in max_rows:
            for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
            if flg:
                break

     ans < m ans m for row in max_rows:
            for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
            if flg:
                break

     row max_rows for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
             col max_cols if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
             not col in row_col_dict[row] col in row_col_dict[row] col row_col_dict[row] row_col_dict row ans += 1 ans 1 flg = True flg True break if flg:
                break

     flg break print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    _, _, m = map(int, input().split())

    row_dict = defaultdict(int)
    col_dict = defaultdict(int)
    row_col_dict = defaultdict(set)
    for _ in range(m):
        row, col = map(int, input().split())
        row_dict[row] += 1
        col_dict[col] += 1
        row_col_dict[row].add(col)

    max_row_val = max(row_dict.values())
    max_col_val = max(col_dict.values())

    max_rows = {k for k, v in row_dict.items() if v == max_row_val}
    max_cols = {k for k, v in col_dict.items() if v == max_col_val}
    ans = max_row_val + max_col_val - 1
    flg = False
    if ans < m:
        for row in max_rows:
            for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
            if flg:
                break

    print(ans) def main():
    _, _, m = map(int, input().split())

    row_dict = defaultdict(int)
    col_dict = defaultdict(int)
    row_col_dict = defaultdict(set)
    for _ in range(m):
        row, col = map(int, input().split())
        row_dict[row] += 1
        col_dict[col] += 1
        row_col_dict[row].add(col)

    max_row_val = max(row_dict.values())
    max_col_val = max(col_dict.values())

    max_rows = {k for k, v in row_dict.items() if v == max_row_val}
    max_cols = {k for k, v in col_dict.items() if v == max_col_val}
    ans = max_row_val + max_col_val - 1
    flg = False
    if ans < m:
        for row in max_rows:
            for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
            if flg:
                break

    print(ans) main
from collections import defaultdict


def main():
    _, _, m = map(int, input().split())

    row_dict = defaultdict(int)
    col_dict = defaultdict(int)
    row_col_dict = defaultdict(set)
    for _ in range(m):
        row, col = map(int, input().split())
        row_dict[row] += 1
        col_dict[col] += 1
        row_col_dict[row].add(col)

    max_row_val = max(row_dict.values())
    max_col_val = max(col_dict.values())

    max_rows = {k for k, v in row_dict.items() if v == max_row_val}
    max_cols = {k for k, v in col_dict.items() if v == max_col_val}
    ans = max_row_val + max_col_val - 1
    flg = False
    if ans < m:
        for row in max_rows:
            for col in max_cols:
                if not col in row_col_dict[row]:
                    ans += 1
                    flg = True
                    break
            if flg:
                break

    print(ans)


if __name__ == '__main__':
    main()
