import sys
from collections import deque
H, W, M = map(int, input().split())
S = list(tuple(map(int, input().split())) for _ in range(M))
hh = dict()
ww = dict()
for i in range(M):
    h, w = S[i]
    if h in hh.keys():
        hh[h] += 1
    else:
        hh[h] = 1
    if w in ww.keys():
        ww[w] += 1
    else:
        ww[w] = 1
hhh = sorted(hh.items(), key=lambda x:x[1], reverse=True)
www = sorted(ww.items(), key=lambda x:x[1], reverse=True)
h = hhh[0][1]
w = www[0][1]
ans = h+w
Nh = 0
Nw = 0
for i in range(len(hhh)):
    if h == hhh[i][1]:
        Nh += 1
    else:
        break
for i in range(len(www)):
    if w == www[i][1]:
        Nw += 1
    else:
        break
tt = Nh*Nw
if tt > M:
    print(ans)
    sys.exit()

for tmp in S:
    if hh[tmp[0]] == h and ww[tmp[1]] == w:
        tt -= 1
if tt > 0:
    print(ans)
else:
    print(ans-1) import sys sys from collections import deque H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M S = list(tuple(map(int, input().split())) for _ in range(M)) S list(tuple(map(int, input().split())) for _ in range(M)) list tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split hh = dict() hh dict() dict ww = dict() ww dict() dict for i in range(M):
    h, w = S[i]
    if h in hh.keys():
        hh[h] += 1
    else:
        hh[h] = 1
    if w in ww.keys():
        ww[w] += 1
    else:
        ww[w] = 1 i range(M) range M h, w = S[i] h S[i] S i w if h in hh.keys():
        hh[h] += 1
    else:
        hh[h] = 1
     h in hh.keys() h hh.keys() hh.keys hh keys hh[h] += 1 hh[h] hh h 1 hh[h] = 1 hh[h] hh h 1 if w in ww.keys():
        ww[w] += 1
    else:
        ww[w] = 1 w in ww.keys() w ww.keys() ww.keys ww keys ww[w] += 1 ww[w] ww w 1 ww[w] = 1 ww[w] ww w 1 hhh = sorted(hh.items(), key=lambda x:x[1], reverse=True) hhh sorted(hh.items(), key=lambda x:x[1], reverse=True) sorted hh.items() hh.items hh items key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True www = sorted(ww.items(), key=lambda x:x[1], reverse=True) www sorted(ww.items(), key=lambda x:x[1], reverse=True) sorted ww.items() ww.items ww items key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True h = hhh[0][1] h hhh[0][1] [0] hhh 0 1 w = www[0][1] w www[0][1] [0] www 0 1 ans = h+w ans h+w h w Nh = 0 Nh 0 Nw = 0 Nw 0 for i in range(len(hhh)):
    if h == hhh[i][1]:
        Nh += 1
    else:
        break i range(len(hhh)) range len(hhh) len hhh if h == hhh[i][1]:
        Nh += 1
    else:
        break h == hhh[i][1] h hhh[i][1] [i] hhh i 1 Nh += 1 Nh 1 break for i in range(len(www)):
    if w == www[i][1]:
        Nw += 1
    else:
        break i range(len(www)) range len(www) len www if w == www[i][1]:
        Nw += 1
    else:
        break w == www[i][1] w www[i][1] [i] www i 1 Nw += 1 Nw 1 break tt = Nh*Nw tt Nh*Nw Nh Nw if tt > M:
    print(ans)
    sys.exit() tt > M tt M print(ans) print ans sys.exit() sys.exit sys exit for tmp in S:
    if hh[tmp[0]] == h and ww[tmp[1]] == w:
        tt -= 1 tmp S if hh[tmp[0]] == h and ww[tmp[1]] == w:
        tt -= 1 hh[tmp[0]] == h and ww[tmp[1]] == w hh[tmp[0]] == h hh[tmp[0]] hh tmp[0] tmp 0 h ww[tmp[1]] == w ww[tmp[1]] ww tmp[1] tmp 1 w tt -= 1 tt 1 if tt > 0:
    print(ans)
else:
    print(ans-1) tt > 0 tt 0 print(ans) print ans print(ans-1) print ans-1 ans 1 hhh = sorted(hh.items(), key=lambda x:x[1], reverse=True) sorted(hh.items(), key=lambda x:x[1], reverse=True) hhh M = map(int, input().split()) map(int, input().split()) M tt -= 1 1 tt w = www[0][1] www[0][1] w ans = h+w h+w ans Nh = 0 0 Nh tt = Nh*Nw Nh*Nw tt W, M = map(int, input().split()) map(int, input().split()) W h = hhh[0][1] hhh[0][1] h H, W, M = map(int, input().split()) map(int, input().split()) H Nh += 1 1 Nh Nw += 1 1 Nw h, w = S[i] S[i] h w = S[i] S[i] w ww = dict() dict() ww Nw = 0 0 Nw www = sorted(ww.items(), key=lambda x:x[1], reverse=True) sorted(ww.items(), key=lambda x:x[1], reverse=True) www S = list(tuple(map(int, input().split())) for _ in range(M)) list(tuple(map(int, input().split())) for _ in range(M)) S hh = dict() dict() hh
import sys
from collections import deque
H, W, M = map(int, input().split())
S = list(tuple(map(int, input().split())) for _ in range(M))
hh = dict()
ww = dict()
for i in range(M):
    h, w = S[i]
    if h in hh.keys():
        hh[h] += 1
    else:
        hh[h] = 1
    if w in ww.keys():
        ww[w] += 1
    else:
        ww[w] = 1
hhh = sorted(hh.items(), key=lambda x:x[1], reverse=True)
www = sorted(ww.items(), key=lambda x:x[1], reverse=True)
h = hhh[0][1]
w = www[0][1]
ans = h+w
Nh = 0
Nw = 0
for i in range(len(hhh)):
    if h == hhh[i][1]:
        Nh += 1
    else:
        break
for i in range(len(www)):
    if w == www[i][1]:
        Nw += 1
    else:
        break
tt = Nh*Nw
if tt > M:
    print(ans)
    sys.exit()

for tmp in S:
    if hh[tmp[0]] == h and ww[tmp[1]] == w:
        tt -= 1
if tt > 0:
    print(ans)
else:
    print(ans-1)
