import sys
from collections import defaultdict,Counter
input = sys.stdin.readline
h,w,m=map(int, input().split())
hs=[]
ws=[]
hw=defaultdict(int)
for i in range(m):
    h0,w0=map(int, input().split())
    hw[(h0,w0)]+=1
    hs.append(h0)
    ws.append(w0)

hd=Counter(hs)
wd=Counter(ws)
hmax=max(hd.values())
wmax=max(wd.values())

max_h_list=[kv[0] for kv in hd.items() if kv[1] == hmax]
max_w_list=[kv[0] for kv in wd.items() if kv[1] == wmax]
ans=float('inf')

for x in max_h_list:
    for y in max_w_list:
        if hw[(x,y)]==1:
            ans=min(ans,1)
        else:
            ans=min(ans,0)
            break
print(hmax+wmax-ans) import sys sys from collections import defaultdict,Counter 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 hs=[] hs [] ws=[] ws [] hw=defaultdict(int) hw defaultdict(int) defaultdict int for i in range(m):
    h0,w0=map(int, input().split())
    hw[(h0,w0)]+=1
    hs.append(h0)
    ws.append(w0) i range(m) range m h0,w0=map(int, input().split()) h0 map(int, input().split()) map int input().split() ().split () input split w0 hw[(h0,w0)]+=1 hw[(h0,w0)] hw (h0,w0) h0 w0 1 hs.append(h0) hs.append hs append h0 ws.append(w0) ws.append ws append w0 hd=Counter(hs) hd Counter(hs) Counter hs wd=Counter(ws) wd Counter(ws) Counter ws hmax=max(hd.values()) hmax max(hd.values()) max hd.values() hd.values hd values wmax=max(wd.values()) wmax max(wd.values()) max wd.values() wd.values wd values kv[0] for kv in hd.items() if kv[1] == hmax for kv in hd.items() if kv[1] == hmax kv hd.items() hd.items hd items kv[1] == hmax kv[1] kv 1 hmax if kv[1] == hmax kv[0] kv 0 max_h_list=[kv[0] for kv in hd.items() if kv[1] == hmax] max_h_list [kv[0] for kv in hd.items() if kv[1] == hmax] kv[0] for kv in wd.items() if kv[1] == wmax for kv in wd.items() if kv[1] == wmax kv wd.items() wd.items wd items kv[1] == wmax kv[1] kv 1 wmax if kv[1] == wmax kv[0] kv 0 max_w_list=[kv[0] for kv in wd.items() if kv[1] == wmax] max_w_list [kv[0] for kv in wd.items() if kv[1] == wmax] ans=float('inf') ans float('inf') float 'inf' for x in max_h_list:
    for y in max_w_list:
        if hw[(x,y)]==1:
            ans=min(ans,1)
        else:
            ans=min(ans,0)
            break x max_h_list for y in max_w_list:
        if hw[(x,y)]==1:
            ans=min(ans,1)
        else:
            ans=min(ans,0)
            break y max_w_list if hw[(x,y)]==1:
            ans=min(ans,1)
        else:
            ans=min(ans,0)
            break hw[(x,y)]==1 hw[(x,y)] hw (x,y) x y 1 ans=min(ans,1) ans min(ans,1) min ans 1 ans=min(ans,0) ans min(ans,0) min ans 0 break print(hmax+wmax-ans) print hmax+wmax-ans hmax+wmax hmax wmax ans ws=[] [] ws hmax=max(hd.values()) max(hd.values()) hmax wmax=max(wd.values()) max(wd.values()) wmax w,m=map(int, input().split()) map(int, input().split()) w ans=min(ans,1) min(ans,1) ans input = sys.stdin.readline sys.stdin.readline input wd=Counter(ws) Counter(ws) wd hw=defaultdict(int) defaultdict(int) hw h0,w0=map(int, input().split()) map(int, input().split()) h0 m=map(int, input().split()) map(int, input().split()) m ans=min(ans,0) min(ans,0) ans w0=map(int, input().split()) map(int, input().split()) w0 ans=float('inf') float('inf') ans max_w_list=[kv[0] for kv in wd.items() if kv[1] == wmax] [kv[0] for kv in wd.items() if kv[1] == wmax] max_w_list h,w,m=map(int, input().split()) map(int, input().split()) h max_h_list=[kv[0] for kv in hd.items() if kv[1] == hmax] [kv[0] for kv in hd.items() if kv[1] == hmax] max_h_list hd=Counter(hs) Counter(hs) hd hs=[] [] hs
import sys
from collections import defaultdict,Counter
input = sys.stdin.readline
h,w,m=map(int, input().split())
hs=[]
ws=[]
hw=defaultdict(int)
for i in range(m):
    h0,w0=map(int, input().split())
    hw[(h0,w0)]+=1
    hs.append(h0)
    ws.append(w0)

hd=Counter(hs)
wd=Counter(ws)
hmax=max(hd.values())
wmax=max(wd.values())

max_h_list=[kv[0] for kv in hd.items() if kv[1] == hmax]
max_w_list=[kv[0] for kv in wd.items() if kv[1] == wmax]
ans=float('inf')

for x in max_h_list:
    for y in max_w_list:
        if hw[(x,y)]==1:
            ans=min(ans,1)
        else:
            ans=min(ans,0)
            break
print(hmax+wmax-ans)