from collections import defaultdict



h, w, m = list(map(int, input().split()))



row_dict = defaultdict(int)

col_dict = defaultdict(int)

row_col_dict = defaultdict(set)

for _ in range(m):

    row, col = list(map(int, input().split()))

    row_dict[row] += 1

    col_dict[col] += 1

    row_col_dict[row].add(col)



max_row = max(row_dict.values())

max_col = max(col_dict.values())



max_rows = [k for k, v in list(row_dict.items()) if v == max_row]

max_cols = [k for k, v in list(col_dict.items()) if v == max_col]

ans = max_row + max_col - 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)

from collections import defaultdict



h, w, m = list(map(int, input().split()))



row_dict = defaultdict(int)

col_dict = defaultdict(int)

row_col_dict = defaultdict(set)

for _ in range(m):

    row, col = list(map(int, input().split()))

    row_dict[row] += 1

    col_dict[col] += 1

    row_col_dict[row].add(col)



max_row = max(row_dict.values())

max_col = max(col_dict.values())



max_rows = {k for k, v in list(row_dict.items()) if v == max_row}

max_cols = {k for k, v in list(col_dict.items()) if v == max_col}

ans = max_row + max_col - 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)

from collections import defaultdict

h, w, m = list(map(int, input().split()))
row_dict = defaultdict(int)
col_dict = defaultdict(int)
row_col_dict = defaultdict(set)
for _ in range(m):
    row, col = list(map(int, input().split()))
    row_dict[row] += 1
    col_dict[col] += 1
    row_col_dict[row].add(col)
max_row = max(row_dict.values())
max_col = max(col_dict.values())
max_rows = [k for k, v in list(row_dict.items()) if v == max_row]
max_cols = [k for k, v in list(col_dict.items()) if v == max_col]
ans = max_row + max_col - 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)

from collections import defaultdict

h, w, m = list(map(int, input().split()))
row_dict = defaultdict(int)
col_dict = defaultdict(int)
row_col_dict = defaultdict(set)
for _ in range(m):
    row, col = list(map(int, input().split()))
    row_dict[row] += 1
    col_dict[col] += 1
    row_col_dict[row].add(col)
max_row = max(row_dict.values())
max_col = max(col_dict.values())
max_rows = {k for k, v in list(row_dict.items()) if v == max_row}
max_cols = {k for k, v in list(col_dict.items()) if v == max_col}
ans = max_row + max_col - 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)

-max_rows = [k for k, v in list(row_dict.items()) if v == max_row] -max_cols = [k for k, v in list(col_dict.items()) if v == max_col] +max_rows = {k for k, v in list(row_dict.items()) if v == max_row} +max_cols = {k for k, v in list(col_dict.items()) if v == max_col}