import sys
input = sys.stdin.readline
h,w,m = map(int,input().rstrip().split())
hw = [list(map(int,input().rstrip().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)
bombpoint = set()

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.add((x,y))

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit()
print(ans - 1) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline h,w,m = map(int,input().rstrip().split()) h map(int,input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split w m list(map(int,input().rstrip().split()))for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().rstrip().split())) list map(int,input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split hw = [list(map(int,input().rstrip().split()))for _ in range(m)] hw [list(map(int,input().rstrip().split()))for _ in range(m)] tate = [0]*(h+1) tate [0]*(h+1) [0] 0 h+1 h 1 yoko = [0]*(w+1) yoko [0]*(w+1) [0] 0 w+1 w 1 bombpoint = set() bombpoint set() set for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.add((x,y)) x y hw tate[x] += 1 tate[x] tate x 1 yoko[y] += 1 yoko[y] yoko y 1 bombpoint.add((x,y)) bombpoint.add bombpoint add (x,y) x y ans_x = [] ans_x [] ans_y = [] ans_y [] x_max = max(tate) x_max max(tate) max tate y_max = max(yoko) y_max max(yoko) max yoko for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i) i range(len(tate)) range len(tate) len tate if tate[i] == x_max:
        ans_x.append(i) tate[i] == x_max tate[i] tate i x_max ans_x.append(i) ans_x.append ans_x append i for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i) i range(len(yoko)) range len(yoko) len yoko if yoko[i] == y_max:
        ans_y.append(i) yoko[i] == y_max yoko[i] yoko i y_max ans_y.append(i) ans_y.append ans_y append i ans = x_max + y_max ans x_max + y_max x_max y_max for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit() x ans_x for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit() y ans_y if (x,y) not in bombpoint:
            print(ans)
            exit() (x,y) not in bombpoint (x,y) x y bombpoint print(ans) print ans exit() exit print(ans - 1) print ans - 1 ans 1 hw = [list(map(int,input().rstrip().split()))for _ in range(m)] [list(map(int,input().rstrip().split()))for _ in range(m)] hw h,w,m = map(int,input().rstrip().split()) map(int,input().rstrip().split()) h w,m = map(int,input().rstrip().split()) map(int,input().rstrip().split()) w m = map(int,input().rstrip().split()) map(int,input().rstrip().split()) m y_max = max(yoko) max(yoko) y_max bombpoint = set() set() bombpoint ans = x_max + y_max x_max + y_max ans ans_x = [] [] ans_x tate = [0]*(h+1) [0]*(h+1) tate yoko = [0]*(w+1) [0]*(w+1) yoko input = sys.stdin.readline sys.stdin.readline input ans_y = [] [] ans_y x_max = max(tate) max(tate) x_max
import sys
input = sys.stdin.readline
h,w,m = map(int,input().rstrip().split())
hw = [list(map(int,input().rstrip().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)
bombpoint = set()

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.add((x,y))

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit()
print(ans - 1)