import bisect

H, W, M = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(M)]
hw.sort()

rows, columns = [0]*H, [0]*W
for h, w in hw:
    rows[h-1] += 1
    columns[w-1] += 1
max_r, max_c = max(rows), max(columns)

argmax_r, argmax_c = [], []
for i in range(H):
    if max_r == rows[i]:
        argmax_r.append(i)

for i in range(W):
    if max_c == columns[i]:
        argmax_c.append(i)

for r in argmax_r:
    for c in argmax_c:
        idx = bisect.bisect_left(hw, [r+1, c+1])
        if idx == M or hw[idx] != [r+1,c+1]:
            print(max_r + max_c)
            exit()

print(max_r + max_c - 1) import bisect bisect H, W, M = map(int,input().split()) H map(int,input().split()) map int input().split() ().split () input split W M list(map(int,input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split hw = [list(map(int,input().split())) for _ in range(M)] hw [list(map(int,input().split())) for _ in range(M)] hw.sort() hw.sort hw sort rows, columns = [0]*H, [0]*W rows [0]*H [0] 0 H columns [0]*W [0] 0 W for h, w in hw:
    rows[h-1] += 1
    columns[w-1] += 1 h w hw rows[h-1] += 1 rows[h-1] rows h-1 h 1 1 columns[w-1] += 1 columns[w-1] columns w-1 w 1 1 max_r, max_c = max(rows), max(columns) max_r max(rows) max rows max_c max(columns) max columns argmax_r, argmax_c = [], [] argmax_r [] argmax_c [] for i in range(H):
    if max_r == rows[i]:
        argmax_r.append(i) i range(H) range H if max_r == rows[i]:
        argmax_r.append(i) max_r == rows[i] max_r rows[i] rows i argmax_r.append(i) argmax_r.append argmax_r append i for i in range(W):
    if max_c == columns[i]:
        argmax_c.append(i) i range(W) range W if max_c == columns[i]:
        argmax_c.append(i) max_c == columns[i] max_c columns[i] columns i argmax_c.append(i) argmax_c.append argmax_c append i for r in argmax_r:
    for c in argmax_c:
        idx = bisect.bisect_left(hw, [r+1, c+1])
        if idx == M or hw[idx] != [r+1,c+1]:
            print(max_r + max_c)
            exit() r argmax_r for c in argmax_c:
        idx = bisect.bisect_left(hw, [r+1, c+1])
        if idx == M or hw[idx] != [r+1,c+1]:
            print(max_r + max_c)
            exit() c argmax_c idx = bisect.bisect_left(hw, [r+1, c+1]) idx bisect.bisect_left(hw, [r+1, c+1]) bisect.bisect_left bisect bisect_left hw [r+1, c+1] r+1 r 1 c+1 c 1 if idx == M or hw[idx] != [r+1,c+1]:
            print(max_r + max_c)
            exit() idx == M or hw[idx] != [r+1,c+1] idx == M idx M hw[idx] != [r+1,c+1] hw[idx] hw idx [r+1,c+1] r+1 r 1 c+1 c 1 print(max_r + max_c) print max_r + max_c max_r max_c exit() exit print(max_r + max_c - 1) print max_r + max_c - 1 max_r + max_c max_r max_c 1 columns = [0]*H, [0]*W [0]*W columns hw = [list(map(int,input().split())) for _ in range(M)] [list(map(int,input().split())) for _ in range(M)] hw M = map(int,input().split()) map(int,input().split()) M idx = bisect.bisect_left(hw, [r+1, c+1]) bisect.bisect_left(hw, [r+1, c+1]) idx W, M = map(int,input().split()) map(int,input().split()) W argmax_c = [], [] [] argmax_c max_c = max(rows), max(columns) max(columns) max_c max_r, max_c = max(rows), max(columns) max(rows) max_r H, W, M = map(int,input().split()) map(int,input().split()) H argmax_r, argmax_c = [], [] [] argmax_r rows, columns = [0]*H, [0]*W [0]*H rows
import bisect

H, W, M = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(M)]
hw.sort()

rows, columns = [0]*H, [0]*W
for h, w in hw:
    rows[h-1] += 1
    columns[w-1] += 1
max_r, max_c = max(rows), max(columns)

argmax_r, argmax_c = [], []
for i in range(H):
    if max_r == rows[i]:
        argmax_r.append(i)

for i in range(W):
    if max_c == columns[i]:
        argmax_c.append(i)

for r in argmax_r:
    for c in argmax_c:
        idx = bisect.bisect_left(hw, [r+1, c+1])
        if idx == M or hw[idx] != [r+1,c+1]:
            print(max_r + max_c)
            exit()

print(max_r + max_c - 1)