import sys
input = sys.stdin.readline
H, W, M = map(int, input().split())
bombs = []
rows = [[]for _ in range(H)]
cols = [[]for _ in range(W)]
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    bombs.append((h, w))
    rows[h].append(w)
    cols[w].append(h)

max_row = 0
row_idx = set()
for i, row in enumerate(rows):
    if max_row < len(row):
        max_row = len(row)
        row_idx = {i}
        continue
    elif max_row == len(row):
        row_idx.add(i)

max_col = 0
col_idx = set()
for i, col in enumerate(cols):
    if max_col < len(col):
        max_col = len(col)
        col_idx = {i}
        continue
    elif max_col == len(col):
        col_idx.add(i)

ans = max_row+max_col
points = len(row_idx)*len(col_idx)
if M < points:
    print(ans)
else:
    for i, j in bombs:
        if i in row_idx and j in col_idx:
            points -= 1
    if points == 0:
        print(ans-1)
    else:
        print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M bombs = [] bombs [] []for _ in range(H) for _ in range(H) _ range(H) range H for _ in range(H) [] rows = [[]for _ in range(H)] rows [[]for _ in range(H)] []for _ in range(W) for _ in range(W) _ range(W) range W for _ in range(W) [] cols = [[]for _ in range(W)] cols [[]for _ in range(W)] for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    bombs.append((h, w))
    rows[h].append(w)
    cols[w].append(h) _ range(M) range M h, w = map(lambda x: int(x)-1, input().split()) h map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split w bombs.append((h, w)) bombs.append bombs append (h, w) h w rows[h].append(w) [h].append [h] rows h append w cols[w].append(h) [w].append [w] cols w append h max_row = 0 max_row 0 row_idx = set() row_idx set() set for i, row in enumerate(rows):
    if max_row < len(row):
        max_row = len(row)
        row_idx = {i}
        continue
    elif max_row == len(row):
        row_idx.add(i) i row enumerate(rows) enumerate rows if max_row < len(row):
        max_row = len(row)
        row_idx = {i}
        continue
    elif max_row == len(row):
        row_idx.add(i) max_row < len(row) max_row len(row) len row max_row = len(row) max_row len(row) len row row_idx = {i} row_idx {i} continue elif max_row == len(row):
        row_idx.add(i) max_row == len(row) max_row len(row) len row row_idx.add(i) row_idx.add row_idx add i max_col = 0 max_col 0 col_idx = set() col_idx set() set for i, col in enumerate(cols):
    if max_col < len(col):
        max_col = len(col)
        col_idx = {i}
        continue
    elif max_col == len(col):
        col_idx.add(i) i col enumerate(cols) enumerate cols if max_col < len(col):
        max_col = len(col)
        col_idx = {i}
        continue
    elif max_col == len(col):
        col_idx.add(i) max_col < len(col) max_col len(col) len col max_col = len(col) max_col len(col) len col col_idx = {i} col_idx {i} continue elif max_col == len(col):
        col_idx.add(i) max_col == len(col) max_col len(col) len col col_idx.add(i) col_idx.add col_idx add i ans = max_row+max_col ans max_row+max_col max_row max_col points = len(row_idx)*len(col_idx) points len(row_idx)*len(col_idx) len(row_idx) len row_idx len(col_idx) len col_idx if M < points:
    print(ans)
else:
    for i, j in bombs:
        if i in row_idx and j in col_idx:
            points -= 1
    if points == 0:
        print(ans-1)
    else:
        print(ans) M < points M points print(ans) print ans for i, j in bombs:
        if i in row_idx and j in col_idx:
            points -= 1
     i j bombs if i in row_idx and j in col_idx:
            points -= 1
     i in row_idx and j in col_idx i in row_idx i row_idx j in col_idx j col_idx points -= 1 points 1 if points == 0:
        print(ans-1)
    else:
        print(ans) points == 0 points 0 print(ans-1) print ans-1 ans 1 print(ans) print ans max_row = 0 0 max_row max_row = len(row) len(row) max_row points = len(row_idx)*len(col_idx) len(row_idx)*len(col_idx) points col_idx = set() set() col_idx col_idx = {i} {i} col_idx H, W, M = map(int, input().split()) map(int, input().split()) H cols = [[]for _ in range(W)] [[]for _ in range(W)] cols M = map(int, input().split()) map(int, input().split()) M w = map(lambda x: int(x)-1, input().split()) map(lambda x: int(x)-1, input().split()) w row_idx = {i} {i} row_idx row_idx = set() set() row_idx bombs = [] [] bombs W, M = map(int, input().split()) map(int, input().split()) W input = sys.stdin.readline sys.stdin.readline input h, w = map(lambda x: int(x)-1, input().split()) map(lambda x: int(x)-1, input().split()) h rows = [[]for _ in range(H)] [[]for _ in range(H)] rows ans = max_row+max_col max_row+max_col ans points -= 1 1 points max_col = len(col) len(col) max_col max_col = 0 0 max_col
import sys
input = sys.stdin.readline
H, W, M = map(int, input().split())
bombs = []
rows = [[]for _ in range(H)]
cols = [[]for _ in range(W)]
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    bombs.append((h, w))
    rows[h].append(w)
    cols[w].append(h)

max_row = 0
row_idx = set()
for i, row in enumerate(rows):
    if max_row < len(row):
        max_row = len(row)
        row_idx = {i}
        continue
    elif max_row == len(row):
        row_idx.add(i)

max_col = 0
col_idx = set()
for i, col in enumerate(cols):
    if max_col < len(col):
        max_col = len(col)
        col_idx = {i}
        continue
    elif max_col == len(col):
        col_idx.add(i)

ans = max_row+max_col
points = len(row_idx)*len(col_idx)
if M < points:
    print(ans)
else:
    for i, j in bombs:
        if i in row_idx and j in col_idx:
            points -= 1
    if points == 0:
        print(ans-1)
    else:
        print(ans)
